1997-08-17 21:09:35 +00:00
|
|
|
/*-
|
2017-11-26 02:00:33 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
2012-01-07 16:13:56 +00:00
|
|
|
* Copyright (c) 1991-1997 Søren Schmidt
|
1997-08-17 21:09:35 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer
|
|
|
|
* in this position and unchanged.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
2002-06-02 20:05:59 +00:00
|
|
|
* derived from this software without specific prior written permission
|
1997-08-17 21:09:35 +00:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-09-16 21:35:07 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2019-03-29 15:57:08 +00:00
|
|
|
#include <signal.h>
|
1997-08-17 21:09:35 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/mman.h>
|
2000-10-08 21:34:00 +00:00
|
|
|
#include <sys/fbio.h>
|
|
|
|
#include <sys/kbio.h>
|
|
|
|
#include <sys/consio.h>
|
1997-08-17 21:09:35 +00:00
|
|
|
#include "vgl.h"
|
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
#define min(x, y) (((x) < (y)) ? (x) : (y))
|
|
|
|
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLBitmap *VGLDisplay;
|
2019-04-21 16:17:35 +00:00
|
|
|
VGLBitmap VGLVDisplay;
|
1999-11-08 11:37:46 +00:00
|
|
|
video_info_t VGLModeInfo;
|
|
|
|
video_adapter_info_t VGLAdpInfo;
|
|
|
|
byte *VGLBuf;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
|
|
|
static int VGLMode;
|
|
|
|
static int VGLOldMode;
|
1999-11-08 11:37:46 +00:00
|
|
|
static size_t VGLBufSize;
|
|
|
|
static byte *VGLMem = MAP_FAILED;
|
1997-08-17 21:09:35 +00:00
|
|
|
static int VGLSwitchPending;
|
2001-07-24 11:15:20 +00:00
|
|
|
static int VGLAbortPending;
|
1997-08-17 21:09:35 +00:00
|
|
|
static int VGLOnDisplay;
|
1999-11-08 11:37:46 +00:00
|
|
|
static unsigned int VGLCurWindow;
|
1997-10-01 20:53:41 +00:00
|
|
|
static int VGLInitDone = 0;
|
2019-03-29 16:30:19 +00:00
|
|
|
static video_info_t VGLOldModeInfo;
|
2001-05-19 17:05:52 +00:00
|
|
|
static vid_info_t VGLOldVInfo;
|
2019-04-26 13:22:54 +00:00
|
|
|
static int VGLOldVXsize;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
VGLEnd()
|
|
|
|
{
|
|
|
|
struct vt_mode smode;
|
2019-03-29 16:30:19 +00:00
|
|
|
int size[3];
|
1997-08-17 21:09:35 +00:00
|
|
|
|
1997-10-01 20:53:41 +00:00
|
|
|
if (!VGLInitDone)
|
|
|
|
return;
|
2019-04-25 15:48:23 +00:00
|
|
|
VGLInitDone = 0;
|
2019-04-24 13:15:56 +00:00
|
|
|
signal(SIGUSR1, SIG_IGN);
|
|
|
|
signal(SIGUSR2, SIG_IGN);
|
2001-07-24 11:15:20 +00:00
|
|
|
VGLSwitchPending = 0;
|
|
|
|
VGLAbortPending = 0;
|
2019-04-29 14:13:53 +00:00
|
|
|
VGLMouseMode(VGL_MOUSEHIDE);
|
1999-11-08 11:37:46 +00:00
|
|
|
|
|
|
|
if (VGLMem != MAP_FAILED) {
|
|
|
|
VGLClear(VGLDisplay, 0);
|
|
|
|
munmap(VGLMem, VGLAdpInfo.va_window_size);
|
1999-08-28 02:39:10 +00:00
|
|
|
}
|
1999-11-08 11:37:46 +00:00
|
|
|
|
2019-04-26 13:22:54 +00:00
|
|
|
ioctl(0, FBIO_SETLINEWIDTH, &VGLOldVXsize);
|
|
|
|
|
2019-03-29 16:30:19 +00:00
|
|
|
if (VGLOldMode >= M_VESA_BASE)
|
1999-08-22 03:31:13 +00:00
|
|
|
ioctl(0, _IO('V', VGLOldMode - M_VESA_BASE), 0);
|
2019-03-29 16:30:19 +00:00
|
|
|
else
|
1999-08-22 03:31:13 +00:00
|
|
|
ioctl(0, _IO('S', VGLOldMode), 0);
|
2019-03-29 16:30:19 +00:00
|
|
|
if (VGLOldModeInfo.vi_flags & V_INFO_GRAPHICS) {
|
|
|
|
size[0] = VGLOldVInfo.mv_csz;
|
|
|
|
size[1] = VGLOldVInfo.mv_rsz;
|
|
|
|
size[2] = VGLOldVInfo.font_size;;
|
|
|
|
ioctl(0, KDRASTER, size);
|
1999-08-22 03:31:13 +00:00
|
|
|
}
|
2019-04-20 20:29:03 +00:00
|
|
|
if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT)
|
|
|
|
ioctl(0, KDDISABIO, 0);
|
1997-08-17 21:09:35 +00:00
|
|
|
ioctl(0, KDSETMODE, KD_TEXT);
|
|
|
|
smode.mode = VT_AUTO;
|
|
|
|
ioctl(0, VT_SETMODE, &smode);
|
1999-11-08 11:37:46 +00:00
|
|
|
if (VGLBuf)
|
|
|
|
free(VGLBuf);
|
|
|
|
VGLBuf = NULL;
|
1997-08-17 21:09:35 +00:00
|
|
|
free(VGLDisplay);
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay = NULL;
|
1997-10-01 20:53:41 +00:00
|
|
|
VGLKeyboardEnd();
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-03-29 15:57:08 +00:00
|
|
|
VGLAbort(int arg)
|
1997-08-17 21:09:35 +00:00
|
|
|
{
|
2019-03-29 15:57:08 +00:00
|
|
|
sigset_t mask;
|
|
|
|
|
2001-07-24 11:15:20 +00:00
|
|
|
VGLAbortPending = 1;
|
|
|
|
signal(SIGINT, SIG_IGN);
|
|
|
|
signal(SIGTERM, SIG_IGN);
|
|
|
|
signal(SIGUSR2, SIG_IGN);
|
2019-03-29 15:57:08 +00:00
|
|
|
if (arg == SIGBUS || arg == SIGSEGV) {
|
|
|
|
signal(arg, SIG_DFL);
|
|
|
|
sigemptyset(&mask);
|
|
|
|
sigaddset(&mask, arg);
|
|
|
|
sigprocmask(SIG_UNBLOCK, &mask, NULL);
|
|
|
|
VGLEnd();
|
|
|
|
kill(getpid(), arg);
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-06-08 12:24:47 +00:00
|
|
|
VGLSwitch(int arg __unused)
|
1997-08-17 21:09:35 +00:00
|
|
|
{
|
|
|
|
if (!VGLOnDisplay)
|
|
|
|
VGLOnDisplay = 1;
|
|
|
|
else
|
|
|
|
VGLOnDisplay = 0;
|
|
|
|
VGLSwitchPending = 1;
|
|
|
|
signal(SIGUSR1, VGLSwitch);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VGLInit(int mode)
|
|
|
|
{
|
|
|
|
struct vt_mode smode;
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
int adptype, depth;
|
1999-11-08 11:37:46 +00:00
|
|
|
|
|
|
|
if (VGLInitDone)
|
|
|
|
return -1;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
|
|
|
signal(SIGUSR1, VGLSwitch);
|
|
|
|
signal(SIGINT, VGLAbort);
|
1999-08-28 02:39:10 +00:00
|
|
|
signal(SIGTERM, VGLAbort);
|
1997-08-17 21:09:35 +00:00
|
|
|
signal(SIGSEGV, VGLAbort);
|
|
|
|
signal(SIGBUS, VGLAbort);
|
2001-07-24 11:15:20 +00:00
|
|
|
signal(SIGUSR2, SIG_IGN);
|
1997-08-17 21:09:35 +00:00
|
|
|
|
|
|
|
VGLOnDisplay = 1;
|
|
|
|
VGLSwitchPending = 0;
|
2001-07-24 11:15:20 +00:00
|
|
|
VGLAbortPending = 0;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
if (ioctl(0, CONS_GET, &VGLOldMode) || ioctl(0, CONS_CURRENT, &adptype))
|
|
|
|
return -1;
|
|
|
|
if (IOCGROUP(mode) == 'V') /* XXX: this is ugly */
|
|
|
|
VGLModeInfo.vi_mode = (mode & 0x0ff) + M_VESA_BASE;
|
|
|
|
else
|
|
|
|
VGLModeInfo.vi_mode = mode & 0x0ff;
|
|
|
|
if (ioctl(0, CONS_MODEINFO, &VGLModeInfo)) /* FBIO_MODEINFO */
|
|
|
|
return -1;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-03-29 16:30:19 +00:00
|
|
|
/* Save info for old mode to restore font size if old mode is graphics. */
|
|
|
|
VGLOldModeInfo.vi_mode = VGLOldMode;
|
|
|
|
if (ioctl(0, CONS_MODEINFO, &VGLOldModeInfo))
|
|
|
|
return -1;
|
|
|
|
VGLOldVInfo.size = sizeof(VGLOldVInfo);
|
|
|
|
if (ioctl(0, CONS_GETINFO, &VGLOldVInfo))
|
|
|
|
return -1;
|
2001-01-25 16:58:46 +00:00
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay = (VGLBitmap *)malloc(sizeof(VGLBitmap));
|
|
|
|
if (VGLDisplay == NULL)
|
|
|
|
return -2;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
2019-04-20 20:29:03 +00:00
|
|
|
if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT && ioctl(0, KDENABIO, 0)) {
|
1999-11-08 11:37:46 +00:00
|
|
|
free(VGLDisplay);
|
|
|
|
return -3;
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLInitDone = 1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* vi_mem_model specifies the memory model of the current video mode
|
|
|
|
* in -CURRENT.
|
|
|
|
*/
|
|
|
|
switch (VGLModeInfo.vi_mem_model) {
|
|
|
|
case V_INFO_MM_PLANAR:
|
|
|
|
/* we can handle EGA/VGA planner modes only */
|
|
|
|
if (VGLModeInfo.vi_depth != 4 || VGLModeInfo.vi_planes != 4
|
|
|
|
|| (adptype != KD_EGA && adptype != KD_VGA)) {
|
|
|
|
VGLEnd();
|
|
|
|
return -4;
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLDisplay->Type = VIDBUF4;
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
VGLDisplay->PixelBytes = 1;
|
1997-08-17 21:09:35 +00:00
|
|
|
break;
|
1999-11-08 11:37:46 +00:00
|
|
|
case V_INFO_MM_PACKED:
|
|
|
|
/* we can do only 256 color packed modes */
|
|
|
|
if (VGLModeInfo.vi_depth != 8) {
|
|
|
|
VGLEnd();
|
|
|
|
return -4;
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLDisplay->Type = VIDBUF8;
|
2001-01-25 11:01:20 +00:00
|
|
|
VGLDisplay->PixelBytes = 1;
|
1997-08-17 21:09:35 +00:00
|
|
|
break;
|
1999-11-08 11:37:46 +00:00
|
|
|
case V_INFO_MM_VGAX:
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLDisplay->Type = VIDBUF8X;
|
2001-01-25 11:01:20 +00:00
|
|
|
VGLDisplay->PixelBytes = 1;
|
1997-08-17 21:09:35 +00:00
|
|
|
break;
|
2001-01-13 11:30:17 +00:00
|
|
|
case V_INFO_MM_DIRECT:
|
|
|
|
VGLDisplay->PixelBytes = VGLModeInfo.vi_pixel_size;
|
|
|
|
switch (VGLDisplay->PixelBytes) {
|
|
|
|
case 2:
|
|
|
|
VGLDisplay->Type = VIDBUF16;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
VGLDisplay->Type = VIDBUF24;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
VGLDisplay->Type = VIDBUF32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
VGLEnd();
|
|
|
|
return -4;
|
|
|
|
}
|
|
|
|
break;
|
1997-08-17 21:09:35 +00:00
|
|
|
default:
|
|
|
|
VGLEnd();
|
1999-11-08 11:37:46 +00:00
|
|
|
return -4;
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ioctl(0, VT_WAITACTIVE, 0);
|
|
|
|
ioctl(0, KDSETMODE, KD_GRAPHICS);
|
1999-11-08 11:37:46 +00:00
|
|
|
if (ioctl(0, mode, 0)) {
|
|
|
|
VGLEnd();
|
|
|
|
return -5;
|
|
|
|
}
|
|
|
|
if (ioctl(0, CONS_ADPINFO, &VGLAdpInfo)) { /* FBIO_ADPINFO */
|
|
|
|
VGLEnd();
|
|
|
|
return -6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the shadow screen buffer size. In -CURRENT, va_buffer_size
|
|
|
|
* always holds the entire frame buffer size, wheather it's in the linear
|
|
|
|
* mode or windowed mode.
|
|
|
|
* VGLBufSize = VGLAdpInfo.va_buffer_size;
|
|
|
|
* In -STABLE, va_buffer_size holds the frame buffer size, only if
|
|
|
|
* the linear frame buffer mode is supported. Otherwise the field is zero.
|
|
|
|
* We shall calculate the minimal size in this case:
|
|
|
|
* VGLAdpInfo.va_line_width*VGLModeInfo.vi_height*VGLModeInfo.vi_planes
|
|
|
|
* or
|
|
|
|
* VGLAdpInfo.va_window_size*VGLModeInfo.vi_planes;
|
|
|
|
* Use whichever is larger.
|
|
|
|
*/
|
|
|
|
if (VGLAdpInfo.va_buffer_size != 0)
|
|
|
|
VGLBufSize = VGLAdpInfo.va_buffer_size;
|
|
|
|
else
|
|
|
|
VGLBufSize = max(VGLAdpInfo.va_line_width*VGLModeInfo.vi_height,
|
|
|
|
VGLAdpInfo.va_window_size)*VGLModeInfo.vi_planes;
|
Quick fix for slow clearing and context switches of large frame buffers
with old kernels, by breaking the support for large frame buffers in the
same way as for current kernels.
Large frame buffers may be too large to map into kva, and the kernel
(syscons) only uses the first screen page anyway, so r203535, r205557
and 248799 limit the buffer size in VESA modes to the first screen
page, apparently without noticing that this breaks applications by
using the same limit for user mappings as for kernel mappings. In
vgl, this makes the virtual screen the same as the physical screen.
However, this is almost a feature since clearing and switching large
(usually mostly unused) frame buffers takes too long. E.g., on a 16
year old low-end AGP card it takes about 12 seconds to clear the 128MB
frame buffer in old kernels that map it all and also map it with slow
attributes (e.g., uncacheable). Older PCI cards are even slower, but
usually have less memory. Newer PCIe cards are faster, but may have
many GB of memory. Also, vgl malloc()s a shadow buffer with the same
size as the frame buffer, so large frame buffers are even more wasteful
in applications than in the kernel.
Use the same limit in vgl as in newer kernels.
Virtual screens and panning still work in non-VESA modes that have
more than 1 page. The reduced buffer size in the kernel also breaks
mmap() of the last physical page in modes where the reduced size is
not a multiple of the physical page size. The same reduction in vgl
only reduces the virtual screen size.
2019-04-16 15:31:23 +00:00
|
|
|
/*
|
|
|
|
* The above is for old -CURRENT. Current -CURRENT since r203535 and/or
|
|
|
|
* r248799 restricts va_buffer_size to the displayed size in VESA modes to
|
|
|
|
* avoid wasting kva for mapping unused parts of the frame buffer. But all
|
|
|
|
* parts were usable here. Applying the same restriction to user mappings
|
|
|
|
* makes our virtualization useless and breaks our panning, but large frame
|
|
|
|
* buffers are also difficult for us to manage (clearing and switching may
|
|
|
|
* be too slow, and malloc() may fail). Restrict ourselves similarly to
|
|
|
|
* get the same efficiency and bugs for all kernels.
|
|
|
|
*/
|
2019-04-16 15:41:45 +00:00
|
|
|
if (VGLModeInfo.vi_mode >= M_VESA_BASE)
|
2019-04-16 15:52:04 +00:00
|
|
|
VGLBufSize = VGLAdpInfo.va_line_width*VGLModeInfo.vi_height*
|
Quick fix for slow clearing and context switches of large frame buffers
with old kernels, by breaking the support for large frame buffers in the
same way as for current kernels.
Large frame buffers may be too large to map into kva, and the kernel
(syscons) only uses the first screen page anyway, so r203535, r205557
and 248799 limit the buffer size in VESA modes to the first screen
page, apparently without noticing that this breaks applications by
using the same limit for user mappings as for kernel mappings. In
vgl, this makes the virtual screen the same as the physical screen.
However, this is almost a feature since clearing and switching large
(usually mostly unused) frame buffers takes too long. E.g., on a 16
year old low-end AGP card it takes about 12 seconds to clear the 128MB
frame buffer in old kernels that map it all and also map it with slow
attributes (e.g., uncacheable). Older PCI cards are even slower, but
usually have less memory. Newer PCIe cards are faster, but may have
many GB of memory. Also, vgl malloc()s a shadow buffer with the same
size as the frame buffer, so large frame buffers are even more wasteful
in applications than in the kernel.
Use the same limit in vgl as in newer kernels.
Virtual screens and panning still work in non-VESA modes that have
more than 1 page. The reduced buffer size in the kernel also breaks
mmap() of the last physical page in modes where the reduced size is
not a multiple of the physical page size. The same reduction in vgl
only reduces the virtual screen size.
2019-04-16 15:31:23 +00:00
|
|
|
VGLModeInfo.vi_planes;
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLBuf = malloc(VGLBufSize);
|
|
|
|
if (VGLBuf == NULL) {
|
|
|
|
VGLEnd();
|
|
|
|
return -7;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef LIBVGL_DEBUG
|
|
|
|
fprintf(stderr, "VGLBufSize:0x%x\n", VGLBufSize);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* see if we are in the windowed buffer mode or in the linear buffer mode */
|
|
|
|
if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size) {
|
2001-01-13 11:30:17 +00:00
|
|
|
switch (VGLDisplay->Type) {
|
|
|
|
case VIDBUF4:
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay->Type = VIDBUF4S;
|
2001-01-13 11:30:17 +00:00
|
|
|
break;
|
|
|
|
case VIDBUF8:
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay->Type = VIDBUF8S;
|
2001-01-13 11:30:17 +00:00
|
|
|
break;
|
|
|
|
case VIDBUF16:
|
|
|
|
VGLDisplay->Type = VIDBUF16S;
|
|
|
|
break;
|
|
|
|
case VIDBUF24:
|
|
|
|
VGLDisplay->Type = VIDBUF24S;
|
|
|
|
break;
|
|
|
|
case VIDBUF32:
|
|
|
|
VGLDisplay->Type = VIDBUF32S;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
VGLEnd();
|
|
|
|
return -8;
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VGLMode = mode;
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLCurWindow = 0;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay->Xsize = VGLModeInfo.vi_width;
|
|
|
|
VGLDisplay->Ysize = VGLModeInfo.vi_height;
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
depth = VGLModeInfo.vi_depth;
|
|
|
|
if (depth == 15)
|
|
|
|
depth = 16;
|
2019-04-26 13:22:54 +00:00
|
|
|
VGLOldVXsize =
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay->VXsize = VGLAdpInfo.va_line_width
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
*8/(depth/VGLModeInfo.vi_planes);
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay->VYsize = VGLBufSize/VGLModeInfo.vi_planes/VGLAdpInfo.va_line_width;
|
|
|
|
VGLDisplay->Xorigin = 0;
|
|
|
|
VGLDisplay->Yorigin = 0;
|
1997-08-17 21:09:35 +00:00
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLMem = (byte*)mmap(0, VGLAdpInfo.va_window_size, PROT_READ|PROT_WRITE,
|
2019-03-24 16:47:43 +00:00
|
|
|
MAP_FILE | MAP_SHARED, 0, 0);
|
1999-11-08 11:37:46 +00:00
|
|
|
if (VGLMem == MAP_FAILED) {
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLEnd();
|
1999-11-08 11:37:46 +00:00
|
|
|
return -7;
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
VGLDisplay->Bitmap = VGLMem;
|
1999-11-08 11:37:46 +00:00
|
|
|
|
2019-04-21 16:17:35 +00:00
|
|
|
VGLVDisplay = *VGLDisplay;
|
|
|
|
VGLVDisplay.Type = MEMBUF;
|
|
|
|
if (VGLModeInfo.vi_depth < 8)
|
|
|
|
VGLVDisplay.Bitmap = malloc(2 * VGLBufSize);
|
|
|
|
else
|
|
|
|
VGLVDisplay.Bitmap = VGLBuf;
|
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLSavePalette();
|
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
#ifdef LIBVGL_DEBUG
|
|
|
|
fprintf(stderr, "va_line_width:%d\n", VGLAdpInfo.va_line_width);
|
|
|
|
fprintf(stderr, "VGLXsize:%d, Ysize:%d, VXsize:%d, VYsize:%d\n",
|
|
|
|
VGLDisplay->Xsize, VGLDisplay->Ysize,
|
|
|
|
VGLDisplay->VXsize, VGLDisplay->VYsize);
|
|
|
|
#endif
|
|
|
|
|
1997-08-17 21:09:35 +00:00
|
|
|
smode.mode = VT_PROCESS;
|
|
|
|
smode.waitv = 0;
|
|
|
|
smode.relsig = SIGUSR1;
|
|
|
|
smode.acqsig = SIGUSR1;
|
|
|
|
smode.frsig = SIGINT;
|
1999-11-08 11:37:46 +00:00
|
|
|
if (ioctl(0, VT_SETMODE, &smode)) {
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLEnd();
|
1999-11-08 11:37:46 +00:00
|
|
|
return -9;
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
VGLTextSetFontFile((byte*)0);
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLClear(VGLDisplay, 0);
|
1997-08-17 21:09:35 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
VGLCheckSwitch()
|
|
|
|
{
|
2001-07-24 11:15:20 +00:00
|
|
|
if (VGLAbortPending) {
|
|
|
|
VGLEnd();
|
|
|
|
exit(0);
|
|
|
|
}
|
1999-08-28 02:39:10 +00:00
|
|
|
while (VGLSwitchPending) {
|
1997-08-17 21:09:35 +00:00
|
|
|
VGLSwitchPending = 0;
|
|
|
|
if (VGLOnDisplay) {
|
2019-04-20 20:29:03 +00:00
|
|
|
if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT)
|
|
|
|
ioctl(0, KDENABIO, 0);
|
1997-08-17 21:09:35 +00:00
|
|
|
ioctl(0, KDSETMODE, KD_GRAPHICS);
|
|
|
|
ioctl(0, VGLMode, 0);
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLCurWindow = 0;
|
|
|
|
VGLMem = (byte*)mmap(0, VGLAdpInfo.va_window_size, PROT_READ|PROT_WRITE,
|
2019-03-24 16:47:43 +00:00
|
|
|
MAP_FILE | MAP_SHARED, 0, 0);
|
1999-11-08 11:37:46 +00:00
|
|
|
|
|
|
|
/* XXX: what if mmap() has failed! */
|
|
|
|
VGLDisplay->Type = VIDBUF8; /* XXX */
|
|
|
|
switch (VGLModeInfo.vi_mem_model) {
|
|
|
|
case V_INFO_MM_PLANAR:
|
|
|
|
if (VGLModeInfo.vi_depth == 4 && VGLModeInfo.vi_planes == 4) {
|
|
|
|
if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size)
|
|
|
|
VGLDisplay->Type = VIDBUF4S;
|
|
|
|
else
|
|
|
|
VGLDisplay->Type = VIDBUF4;
|
|
|
|
} else {
|
|
|
|
/* shouldn't be happening */
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
break;
|
1999-11-08 11:37:46 +00:00
|
|
|
case V_INFO_MM_PACKED:
|
|
|
|
if (VGLModeInfo.vi_depth == 8) {
|
|
|
|
if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size)
|
|
|
|
VGLDisplay->Type = VIDBUF8S;
|
|
|
|
else
|
|
|
|
VGLDisplay->Type = VIDBUF8;
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
break;
|
1999-11-08 11:37:46 +00:00
|
|
|
case V_INFO_MM_VGAX:
|
|
|
|
VGLDisplay->Type = VIDBUF8X;
|
|
|
|
break;
|
2001-01-13 11:30:17 +00:00
|
|
|
case V_INFO_MM_DIRECT:
|
|
|
|
switch (VGLModeInfo.vi_pixel_size) {
|
|
|
|
case 2:
|
|
|
|
if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size)
|
|
|
|
VGLDisplay->Type = VIDBUF16S;
|
|
|
|
else
|
|
|
|
VGLDisplay->Type = VIDBUF16;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size)
|
|
|
|
VGLDisplay->Type = VIDBUF24S;
|
|
|
|
else
|
|
|
|
VGLDisplay->Type = VIDBUF24;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (VGLBufSize/VGLModeInfo.vi_planes > VGLAdpInfo.va_window_size)
|
|
|
|
VGLDisplay->Type = VIDBUF32S;
|
|
|
|
else
|
|
|
|
VGLDisplay->Type = VIDBUF32;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* shouldn't be happening */
|
|
|
|
break;
|
|
|
|
}
|
1997-08-17 21:09:35 +00:00
|
|
|
default:
|
1999-11-08 11:37:46 +00:00
|
|
|
/* shouldn't be happening */
|
1997-08-17 21:09:35 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-11-08 11:37:46 +00:00
|
|
|
|
|
|
|
VGLDisplay->Bitmap = VGLMem;
|
|
|
|
VGLDisplay->Xsize = VGLModeInfo.vi_width;
|
|
|
|
VGLDisplay->Ysize = VGLModeInfo.vi_height;
|
|
|
|
VGLSetVScreenSize(VGLDisplay, VGLDisplay->VXsize, VGLDisplay->VYsize);
|
2019-04-21 10:33:09 +00:00
|
|
|
VGLRestoreBlank();
|
|
|
|
VGLRestoreBorder();
|
|
|
|
VGLMouseRestore();
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLPanScreen(VGLDisplay, VGLDisplay->Xorigin, VGLDisplay->Yorigin);
|
2019-04-21 16:17:35 +00:00
|
|
|
VGLBitmapCopy(&VGLVDisplay, 0, 0, VGLDisplay, 0, 0,
|
|
|
|
VGLDisplay->VXsize, VGLDisplay->VYsize);
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLRestorePalette();
|
|
|
|
ioctl(0, VT_RELDISP, VT_ACKACQ);
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
else {
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLMem = MAP_FAILED;
|
|
|
|
munmap(VGLDisplay->Bitmap, VGLAdpInfo.va_window_size);
|
1997-08-17 21:09:35 +00:00
|
|
|
ioctl(0, VGLOldMode, 0);
|
|
|
|
ioctl(0, KDSETMODE, KD_TEXT);
|
2019-04-20 20:29:03 +00:00
|
|
|
if (VGLModeInfo.vi_mem_model != V_INFO_MM_DIRECT)
|
|
|
|
ioctl(0, KDDISABIO, 0);
|
1997-08-17 21:09:35 +00:00
|
|
|
ioctl(0, VT_RELDISP, VT_TRUE);
|
|
|
|
VGLDisplay->Bitmap = VGLBuf;
|
|
|
|
VGLDisplay->Type = MEMBUF;
|
1999-11-08 11:37:46 +00:00
|
|
|
VGLDisplay->Xsize = VGLDisplay->VXsize;
|
|
|
|
VGLDisplay->Ysize = VGLDisplay->VYsize;
|
1999-08-28 02:39:10 +00:00
|
|
|
while (!VGLOnDisplay) pause();
|
1997-08-17 21:09:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-11-08 11:37:46 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
VGLSetSegment(unsigned int offset)
|
|
|
|
{
|
|
|
|
if (offset/VGLAdpInfo.va_window_size != VGLCurWindow) {
|
|
|
|
ioctl(0, CONS_SETWINORG, offset); /* FBIO_SETWINORG */
|
|
|
|
VGLCurWindow = offset/VGLAdpInfo.va_window_size;
|
|
|
|
}
|
|
|
|
return (offset%VGLAdpInfo.va_window_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VGLSetVScreenSize(VGLBitmap *object, int VXsize, int VYsize)
|
|
|
|
{
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
int depth;
|
|
|
|
|
1999-11-08 11:37:46 +00:00
|
|
|
if (VXsize < object->Xsize || VYsize < object->Ysize)
|
|
|
|
return -1;
|
|
|
|
if (object->Type == MEMBUF)
|
|
|
|
return -1;
|
|
|
|
if (ioctl(0, FBIO_SETLINEWIDTH, &VXsize))
|
|
|
|
return -1;
|
|
|
|
ioctl(0, CONS_ADPINFO, &VGLAdpInfo); /* FBIO_ADPINFO */
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
depth = VGLModeInfo.vi_depth;
|
|
|
|
if (depth == 15)
|
|
|
|
depth = 16;
|
1999-11-08 11:37:46 +00:00
|
|
|
object->VXsize = VGLAdpInfo.va_line_width
|
Fix buffer overruns in modes with color depth more than 8.
Support for 16-bit and 32-bit Truecolor modes was supposed to be
complete in r70991 of main.c and in nearby revisions for other files, but
it was broken by the overruns in most cases (all cases were the mouse
is enabled, and most cases where bitmaps are used). r70991 also
uninintentionally added support for depths 9-15, 17-23 and 25-31.
Depth 24 was more obviously broken and its support is ifdefed out. In
the other ranges, only depth 15 is common. It was broken by buffer
overruns in all cases.
bitmap.c:
- the static buffer was used even when it was too small (but it was
large enough to often work accidentally in depth 16)
- the size of the dynamically allocated buffer was too small
- the sizing info bitmap->PixelBytes was not inititialzed in the bitmap
constructor. It often ended up as 0 for MEMBUFs, so using it in more
places gave more null pointer accesses. (It is per-bitmap, but since
conversion between bitmaps of different depths is not supported (except
from 4 bits by padding to 8), it would work better if it were global.)
main.c:
- depths were rounded down instead of up to a multiple of 8, so PixelBytes
was 1 too small for depths above 8 except 16, 24 and 32.
- PixelBytes was not initialized for 4-bit planar modes. It isn't really
used for frame buffer accesses in these modes, but needs to be 1 in
MEMBUF images.
mouse.c:
- the mouse cursor buffers were too small.
vgl.h:
- PixelBytes was not initialized in the static bitmap constructor. It
should be initialized to the value for the current mode, but that is
impossible in a static constructor. Initialize it to -1 so as to
fail if it is used without further initialization.
All modes that are supposed to be supported now don't crash in
nontrivial tests, and almost work. Missing uses of PixelBytes now
give in-bounds wrong pointers instead of overruns. Misconversions of
bitmaps give multiple miscolored mouse cursors instead of 1 white one,
and similarly for bitmaps copied through a MEMBUF.
2019-03-24 18:57:03 +00:00
|
|
|
*8/(depth/VGLModeInfo.vi_planes);
|
1999-11-08 11:37:46 +00:00
|
|
|
object->VYsize = VGLBufSize/VGLModeInfo.vi_planes/VGLAdpInfo.va_line_width;
|
|
|
|
if (VYsize < object->VYsize)
|
|
|
|
object->VYsize = VYsize;
|
|
|
|
|
|
|
|
#ifdef LIBVGL_DEBUG
|
|
|
|
fprintf(stderr, "new size: VGLXsize:%d, Ysize:%d, VXsize:%d, VYsize:%d\n",
|
|
|
|
object->Xsize, object->Ysize, object->VXsize, object->VYsize);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
VGLPanScreen(VGLBitmap *object, int x, int y)
|
|
|
|
{
|
|
|
|
video_display_start_t origin;
|
|
|
|
|
|
|
|
if (x < 0 || x + object->Xsize > object->VXsize
|
|
|
|
|| y < 0 || y + object->Ysize > object->VYsize)
|
|
|
|
return -1;
|
|
|
|
if (object->Type == MEMBUF)
|
|
|
|
return 0;
|
|
|
|
origin.x = x;
|
|
|
|
origin.y = y;
|
|
|
|
if (ioctl(0, FBIO_SETDISPSTART, &origin))
|
|
|
|
return -1;
|
|
|
|
object->Xorigin = x;
|
|
|
|
object->Yorigin = y;
|
|
|
|
|
|
|
|
#ifdef LIBVGL_DEBUG
|
|
|
|
fprintf(stderr, "new origin: (%d, %d)\n", x, y);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|