1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-27 16:39:08 +00:00

- Don't assume the line length in the video memory is always the same as

the screen width.
- Store the current video mode information in the `video_adapter' struct.
- The size of the `v_offscreensize' field in the VESA mode information
  block is u_int16, not u_int8.
This commit is contained in:
Kazutaka YOKOTA 1999-02-05 11:52:13 +00:00
parent 533601dc35
commit 1c27745f73
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=43664
10 changed files with 202 additions and 200 deletions

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: console.h,v 1.41 1999/01/01 14:38:29 des Exp $
* $Id: console.h,v 1.42 1999/01/23 16:53:27 dfr Exp $
* from: i386/include console.h,v 1.43
*/
@ -286,6 +286,28 @@ struct ssaver {
long time;
};
/* video mode information block */
struct video_info {
int vi_mode;
int vi_flags;
#define V_INFO_COLOR (1<<0)
#define V_INFO_GRAPHICS (1<<1)
#define V_INFO_LINEAR (1<<2)
#define V_INFO_VESA (1<<3)
int vi_width;
int vi_height;
int vi_cwidth;
int vi_cheight;
int vi_depth;
int vi_planes;
u_int vi_window; /* physical address */
size_t vi_window_size;
size_t vi_window_gran;
u_int vi_buffer; /* physical address */
size_t vi_buffer_size;
/* XXX pixel format, memory model,... */
};
/* adapter infromation block */
struct video_adapter {
int va_index;
@ -318,7 +340,8 @@ struct video_adapter {
int va_initial_mode;
int va_initial_bios_mode;
int va_mode;
int va_mode_flags; /* copy of vi_flags */
struct video_info va_info;
int va_line_width;
void *va_token;
};
@ -341,34 +364,12 @@ struct video_adapter_info {
int va_initial_mode;
int va_initial_bios_mode;
int va_mode;
int va_mode_flags;
int va_line_width;
};
#define V_ADP_PRIMARY 0
#define V_ADP_SECONDARY 1
/* video mode information block */
struct video_info {
int vi_mode;
int vi_flags;
#define V_INFO_COLOR (1<<0)
#define V_INFO_GRAPHICS (1<<1)
#define V_INFO_LINEAR (1<<2)
#define V_INFO_VESA (1<<3)
int vi_width;
int vi_height;
int vi_cwidth;
int vi_cheight;
int vi_depth;
int vi_planes;
u_int vi_window; /* physical address */
size_t vi_window_size;
size_t vi_window_gran;
u_int vi_buffer; /* physical address */
size_t vi_buffer_size;
/* XXX pixel format, memory model,... */
};
struct keyboard_info {
int kb_index; /* kbdio index# */
char kb_name[16]; /* driver name */

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: splash_bmp.c,v 1.4 1999/01/21 18:29:33 yokota Exp $
* $Id: splash_bmp.c,v 1.5 1999/01/26 10:00:02 yokota Exp $
*/
#include <sys/param.h>
@ -216,14 +216,14 @@ fill(BMP_INFO *info, int x, int y, int xsize, int ysize)
int p;
banksize = info->adp->va_window_size;
bank = (info->swidth*y + x)/banksize;
bank = (info->adp->va_line_width*y + x)/banksize;
window = (u_char *)info->adp->va_window;
(*vidsw[info->adp->va_index]->set_win_org)(info->adp, bank*banksize);
while (ysize > 0) {
p = (info->swidth*y + x)%banksize;
p = (info->adp->va_line_width*y + x)%banksize;
for (; (p + xsize <= banksize) && ysize > 0; --ysize, ++y) {
generic_bzero(window + p, xsize);
p += info->swidth;
p += info->adp->va_line_width;
}
if (ysize <= 0)
break;
@ -267,11 +267,11 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
* because 0,0 is bottom-left for DIB, we have to convert.
*/
sofs = ((info->height - (y+1) + (info->sheight - info->height) / 2)
* info->swidth) + x + (info->swidth - info->width) / 2;
* info->adp->va_line_width);
switch(info->sdepth) {
case 1:
sofs = sofs >> 3; /* correct for depth */
sofs += ((x + (info->swidth - info->width) / 2) >> 3);
bofs = x & 0x7; /* offset within byte */
val &= 1; /* mask pixel value */
@ -282,7 +282,7 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
/* XXX only correct for non-interleaved modes */
case 4:
sofs = sofs >> 1; /* correct for depth */
sofs += ((x + (info->swidth - info->width) / 2) >> 1);
bofs = x & 0x1; /* offset within byte */
val &= 0xf; /* mask pixel value */
@ -292,6 +292,7 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
break;
case 8:
sofs += x + (info->swidth - info->width) / 2;
newbank = sofs/info->adp->va_window_size;
if (info->bank != newbank) {
(*vidsw[info->adp->va_index]->set_win_org)(info->adp, newbank*info->adp->va_window_size);

View File

@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: scvidctl.c,v 1.6 1999/01/11 03:18:26 yokota Exp $
* $Id: scvidctl.c,v 1.7 1999/01/19 11:31:16 yokota Exp $
*/
#include "sc.h"
@ -392,11 +392,11 @@ sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p)
((video_adapter_info_t *)data)->va_buffer_size
= scp->adp->va_buffer_size;
((video_adapter_info_t *)data)->va_mode = scp->adp->va_mode;
((video_adapter_info_t *)data)->va_mode_flags = scp->adp->va_mode_flags;
((video_adapter_info_t *)data)->va_initial_mode
= scp->adp->va_initial_mode;
((video_adapter_info_t *)data)->va_initial_bios_mode
= scp->adp->va_initial_bios_mode;
((video_adapter_info_t *)data)->va_line_width = scp->adp->va_line_width;
return 0;
case CONS_GET: /* get current video mode */

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: syscons.c,v 1.296 1999/01/28 17:31:58 dillon Exp $
* $Id: syscons.c,v 1.297 1999/01/30 12:17:30 phk Exp $
*/
#include "sc.h"
@ -2327,7 +2327,7 @@ set_scrn_saver_mode(scr_stat *scp, int mode, u_char *pal, int border)
return 0;
scp->mode = mode;
if (set_mode(scp) == 0) {
if (scp->adp->va_mode_flags & V_INFO_GRAPHICS)
if (scp->adp->va_info.vi_flags & V_INFO_GRAPHICS)
scp->status |= GRAPHICS_MODE;
if (pal != NULL)
load_palette(scp->adp, pal);

View File

@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: console.h,v 1.42 1999/01/01 14:38:28 des Exp $
* $Id: console.h,v 1.43 1999/01/11 03:18:04 yokota Exp $
*/
#ifndef _MACHINE_CONSOLE_H_
@ -285,6 +285,28 @@ struct ssaver {
long time;
};
/* video mode information block */
struct video_info {
int vi_mode;
int vi_flags;
#define V_INFO_COLOR (1<<0)
#define V_INFO_GRAPHICS (1<<1)
#define V_INFO_LINEAR (1<<2)
#define V_INFO_VESA (1<<3)
int vi_width;
int vi_height;
int vi_cwidth;
int vi_cheight;
int vi_depth;
int vi_planes;
u_int vi_window; /* physical address */
size_t vi_window_size;
size_t vi_window_gran;
u_int vi_buffer; /* physical address */
size_t vi_buffer_size;
/* XXX pixel format, memory model,... */
};
/* adapter infromation block */
struct video_adapter {
int va_index;
@ -317,7 +339,8 @@ struct video_adapter {
int va_initial_mode;
int va_initial_bios_mode;
int va_mode;
int va_mode_flags; /* copy of vi_flags */
struct video_info va_info;
int va_line_width;
void *va_token;
};
@ -340,34 +363,12 @@ struct video_adapter_info {
int va_initial_mode;
int va_initial_bios_mode;
int va_mode;
int va_mode_flags;
int va_line_width;
};
#define V_ADP_PRIMARY 0
#define V_ADP_SECONDARY 1
/* video mode information block */
struct video_info {
int vi_mode;
int vi_flags;
#define V_INFO_COLOR (1<<0)
#define V_INFO_GRAPHICS (1<<1)
#define V_INFO_LINEAR (1<<2)
#define V_INFO_VESA (1<<3)
int vi_width;
int vi_height;
int vi_cwidth;
int vi_cheight;
int vi_depth;
int vi_planes;
u_int vi_window; /* physical address */
size_t vi_window_size;
size_t vi_window_gran;
u_int vi_buffer; /* physical address */
size_t vi_buffer_size;
/* XXX pixel format, memory model,... */
};
struct keyboard_info {
int kb_index; /* kbdio index# */
char kb_name[16]; /* driver name */

View File

@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: vesa.h,v 1.3 1999/01/08 12:57:06 yokota Exp $
* $Id: vesa.h,v 1.4 1999/01/11 03:18:20 yokota Exp $
*/
#ifndef _MACHINE_PC_VESA_H
@ -105,7 +105,7 @@ struct vesa_mode
/* 2.0 implementations */
u_int32_t v_lfb;
u_int32_t v_offscreen;
u_int8_t v_offscreensize;
u_int16_t v_offscreensize;
};
#ifdef KERNEL

View File

@ -23,7 +23,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: vesa.c,v 1.14 1999/01/16 12:56:00 yokota Exp $
* $Id: vesa.c,v 1.15 1999/01/17 14:12:48 yokota Exp $
*/
#include "vga.h"
@ -167,6 +167,7 @@ static int vesa_bios_load_palette(int start, int colors, u_char *palette,
#define STATE_ALL (STATE_HW | STATE_DATA | STATE_DAC | STATE_REG)
static int vesa_bios_state_buf_size(void);
static int vesa_bios_save_restore(int code, void *p, size_t size);
static int vesa_bios_get_line_length(void);
static int vesa_map_gen_mode_num(int type, int color, int mode);
static int vesa_translate_flags(u_int16_t vflags);
static void *vesa_fix_ptr(u_int32_t p, u_int16_t seg, u_int16_t off,
@ -335,6 +336,21 @@ vesa_bios_save_restore(int code, void *p, size_t size)
return ((err != 0) || (vmf.vmf_eax != 0x4f));
}
static int
vesa_bios_get_line_length(void)
{
struct vm86frame vmf;
int err;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f06;
vmf.vmf_ebx = 1; /* get scan line length */
err = vm86_intcall(0x10, &vmf);
if ((err != 0) || (vmf.vmf_eax != 0x4f))
return -1;
return vmf.vmf_bx; /* line length in bytes */
}
/* map a generic video mode to a known mode */
static int
vesa_map_gen_mode_num(int type, int color, int mode)
@ -480,8 +496,14 @@ vesa_bios_init(void)
vesa_vmode[modes].vi_window_size = vmode.v_wsize*1024;
vesa_vmode[modes].vi_window_gran = vmode.v_wgran*1024;
vesa_vmode[modes].vi_buffer = vmode.v_lfb;
vesa_vmode[modes].vi_buffer_size = vmode.v_offscreen;
/* XXX */
if (vmode.v_offscreen > vmode.v_lfb)
vesa_vmode[modes].vi_buffer_size
= vmode.v_offscreen - vmode.v_lfb;
else
vesa_vmode[modes].vi_buffer_size = vmode.v_offscreen;
/* pixel format, memory model... */
vesa_vmode[modes].vi_flags
= vesa_translate_flags(vmode.v_modeattr) | V_INFO_VESA;
++modes;
@ -656,9 +678,7 @@ static int
vesa_set_mode(video_adapter_t *adp, int mode)
{
video_info_t info;
#if 0
size_t len;
#endif
if (adp != vesa_adp)
return (*prevvidsw->set_mode)(adp, mode);
@ -740,7 +760,6 @@ vesa_set_mode(video_adapter_t *adp, int mode)
printf("VESA: mode set!\n");
#endif
vesa_adp->va_mode = mode;
vesa_adp->va_mode_flags = info.vi_flags;
vesa_adp->va_flags &= ~V_ADP_COLOR;
vesa_adp->va_flags |=
(info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
@ -756,6 +775,18 @@ vesa_set_mode(video_adapter_t *adp, int mode)
vesa_adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
vesa_adp->va_buffer_size = info.vi_buffer_size;
}
bcopy(&info, &adp->va_info, sizeof(adp->va_info));
len = vesa_bios_get_line_length();
if (len > 0)
adp->va_line_width = len;
else if (info.vi_flags & V_INFO_GRAPHICS)
adp->va_line_width = info.vi_width/8;
else
adp->va_line_width = info.vi_width;
#if VESA_DEBUG > 0
printf("vesa_set_mode(): vi_width:%d, len:%d, line_width:%d\n",
info.vi_width, len, adp->va_line_width);
#endif
/* move hardware cursor out of the way */
(*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
@ -874,7 +905,14 @@ vesa_set_origin(video_adapter_t *adp, off_t offset)
vmf.vmf_ebx = 0; /* WINDOW_A, XXX */
vmf.vmf_edx = offset/vesa_adp->va_window_gran;
err = vm86_intcall(0x10, &vmf);
return ((err != 0) || (vmf.vmf_eax != 0x4f));
if ((err != 0) || (vmf.vmf_eax != 0x4f))
return 1;
bzero(&vmf, sizeof(vmf));
vmf.vmf_eax = 0x4f05;
vmf.vmf_ebx = 1; /* WINDOW_B, XXX */
vmf.vmf_edx = offset/vesa_adp->va_window_gran;
err = vm86_intcall(0x10, &vmf);
return 0; /* XXX */
}
static int

View File

@ -26,7 +26,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: vga_isa.c,v 1.1 1999/01/09 02:44:41 yokota Exp $
* $Id: vga_isa.c,v 1.2 1999/01/23 10:55:16 yokota Exp $
*/
#include "vga.h"
@ -233,7 +233,7 @@ isavga_attach_unit(int unit, isavga_softc_t *sc, int flags)
#endif /* FB_INSTALL_CDEV */
if (bootverbose)
(*sw->diag)(sc->adp, bootverbose);
(*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose);
return 0;
}
@ -297,27 +297,27 @@ static video_adapter_t adapter_init_value[] = {
/* DCC_MONO */
{ 0, KD_MONO, "mda", 0, 0, 0, IO_MDA, IO_MDASIZE, MONO_CRTC,
MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE,
0, 0, 0, 7, 0, 0, NULL },
0, 0, 0, 7, 0, },
/* DCC_CGA40 */
{ 0, KD_CGA, "cga", 0, 0, V_ADP_COLOR, IO_CGA, IO_CGASIZE, COLOR_CRTC,
CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
/* DCC_CGA80 */
{ 0, KD_CGA, "cga", 0, 0, V_ADP_COLOR, IO_CGA, IO_CGASIZE, COLOR_CRTC,
CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
/* DCC_EGAMONO */
{ 0, KD_EGA, "ega", 0, 0, 0, IO_MDA, 48, MONO_CRTC,
EGA_BUF_BASE, EGA_BUF_SIZE, MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE,
0, 0, 0, 7, 0, 0, NULL },
0, 0, 0, 7, 0, },
/* DCC_EGA40 */
{ 0, KD_EGA, "ega", 0, 0, V_ADP_COLOR, IO_MDA, 48, COLOR_CRTC,
EGA_BUF_BASE, EGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
/* DCC_EGA80 */
{ 0, KD_EGA, "ega", 0, 0, V_ADP_COLOR, IO_MDA, 48, COLOR_CRTC,
EGA_BUF_BASE, EGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
};
static video_adapter_t biosadapter[2];
@ -489,6 +489,7 @@ static u_char *get_mode_param(int mode);
static void fill_adapter_param(int code, video_adapter_t *adp);
#endif
static int verify_adapter(video_adapter_t *adp);
static void update_adapter_info(video_adapter_t *adp, video_info_t *info);
#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
#define COMP_IDENTICAL 0
#define COMP_SIMILAR 1
@ -834,6 +835,31 @@ verify_adapter(video_adapter_t *adp)
return 0;
}
static void
update_adapter_info(video_adapter_t *adp, video_info_t *info)
{
adp->va_flags &= ~V_ADP_COLOR;
adp->va_flags |=
(info->vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
adp->va_crtc_addr =
(adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
adp->va_window = BIOS_PADDRTOVADDR(info->vi_window);
adp->va_window_size = info->vi_window_size;
adp->va_window_gran = info->vi_window_gran;
if (info->vi_buffer_size == 0) {
adp->va_buffer = 0;
adp->va_buffer_size = 0;
} else {
adp->va_buffer = BIOS_PADDRTOVADDR(info->vi_buffer);
adp->va_buffer_size = info->vi_buffer_size;
}
if (info->vi_flags & V_INFO_GRAPHICS)
adp->va_line_width = info->vi_width/8;
else
adp->va_line_width = info->vi_width;
bcopy(info, &adp->va_info, sizeof(adp->va_info));
}
#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
/* compare two parameter table entries */
static int
@ -980,10 +1006,6 @@ probe_adapters(void)
}
if (biosadapters == 0)
return biosadapters;
#if 0
biosadapter[V_ADP_PRIMARY].va_index = V_ADP_PRIMARY;
biosadapter[V_ADP_SECONDARY].va_index = V_ADP_SECONDARY;
#endif
biosadapter[V_ADP_PRIMARY].va_unit = V_ADP_PRIMARY;
biosadapter[V_ADP_SECONDARY].va_unit = V_ADP_SECONDARY;
@ -1148,35 +1170,12 @@ probe_adapters(void)
/* buffer address */
vga_get_info(&biosadapter[V_ADP_PRIMARY],
biosadapter[V_ADP_PRIMARY].va_initial_mode, &info);
biosadapter[V_ADP_PRIMARY].va_mode_flags = info.vi_flags;
biosadapter[V_ADP_PRIMARY].va_window = BIOS_PADDRTOVADDR(info.vi_window);
biosadapter[V_ADP_PRIMARY].va_window_size = info.vi_window_size;
biosadapter[V_ADP_PRIMARY].va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
biosadapter[V_ADP_PRIMARY].va_buffer = 0;
biosadapter[V_ADP_PRIMARY].va_buffer_size = 0;
} else {
biosadapter[V_ADP_PRIMARY].va_buffer
= BIOS_PADDRTOVADDR(info.vi_buffer);
biosadapter[V_ADP_PRIMARY].va_buffer_size = info.vi_buffer_size;
}
update_adapter_info(&biosadapter[V_ADP_PRIMARY], &info);
if (biosadapters > 1) {
vga_get_info(&biosadapter[V_ADP_SECONDARY],
biosadapter[V_ADP_SECONDARY].va_initial_mode, &info);
biosadapter[V_ADP_SECONDARY].va_mode_flags = info.vi_flags;
biosadapter[V_ADP_SECONDARY].va_window =
BIOS_PADDRTOVADDR(info.vi_window);
biosadapter[V_ADP_SECONDARY].va_window_size = info.vi_window_size;
biosadapter[V_ADP_SECONDARY].va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
biosadapter[V_ADP_SECONDARY].va_buffer = 0;
biosadapter[V_ADP_SECONDARY].va_buffer_size = 0;
} else {
biosadapter[V_ADP_SECONDARY].va_buffer =
BIOS_PADDRTOVADDR(info.vi_buffer);
biosadapter[V_ADP_SECONDARY].va_buffer_size = info.vi_buffer_size;
}
update_adapter_info(&biosadapter[V_ADP_SECONDARY], &info);
}
/*
@ -1432,22 +1431,7 @@ vga_set_mode(video_adapter_t *adp, int mode)
}
adp->va_mode = mode;
adp->va_mode_flags = info.vi_flags;
adp->va_flags &= ~V_ADP_COLOR;
adp->va_flags |=
(info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
adp->va_crtc_addr =
(adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
adp->va_window_size = info.vi_window_size;
adp->va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
adp->va_buffer = 0;
adp->va_buffer_size = 0;
} else {
adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
adp->va_buffer_size = info.vi_buffer_size;
}
update_adapter_info(adp, &info);
/* move hardware cursor out of the way */
(*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
@ -2013,15 +1997,13 @@ vga_set_origin(video_adapter_t *adp, off_t offset)
static int
vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
{
video_info_t info;
u_int16_t off;
int s;
if (!init_done)
return 1;
(*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info);
if (info.vi_flags & V_INFO_GRAPHICS)
if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
return 1;
s = spltty();
@ -2031,8 +2013,8 @@ vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
off = (off << 8) | inb(adp->va_crtc_addr + 1);
splx(s);
*row = off / info.vi_width;
*col = off % info.vi_width;
*row = off / adp->va_info.vi_width;
*col = off % adp->va_info.vi_width;
return 0;
}
@ -2047,7 +2029,6 @@ vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
static int
vga_set_hw_cursor(video_adapter_t *adp, int col, int row)
{
video_info_t info;
u_int16_t off;
int s;
@ -2057,10 +2038,9 @@ vga_set_hw_cursor(video_adapter_t *adp, int col, int row)
if ((col == -1) && (row == -1)) {
off = -1;
} else {
(*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info);
if (info.vi_flags & V_INFO_GRAPHICS)
if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
return 1;
off = row*info.vi_width + col;
off = row*adp->va_info.vi_width + col;
}
s = spltty();

View File

@ -26,7 +26,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: vga_isa.c,v 1.1 1999/01/09 02:44:41 yokota Exp $
* $Id: vga_isa.c,v 1.1 1999/01/23 16:53:30 dfr Exp $
*/
#include "vga.h"
@ -236,7 +236,7 @@ isavga_attach_unit(int unit, isavga_softc_t *sc, int flags)
#endif /* FB_INSTALL_CDEV */
if (bootverbose)
(*sw->diag)(sc->adp, bootverbose);
(*vidsw[sc->adp->va_index]->diag)(sc->adp, bootverbose);
return 0;
}
@ -300,27 +300,27 @@ static video_adapter_t adapter_init_value[] = {
/* DCC_MONO */
{ 0, KD_MONO, "mda", 0, 0, 0, IO_MDA, IO_MDASIZE, MONO_CRTC,
MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE,
0, 0, 0, 7, 0, 0, NULL },
0, 0, 0, 7, 0, },
/* DCC_CGA40 */
{ 0, KD_CGA, "cga", 0, 0, V_ADP_COLOR, IO_CGA, IO_CGASIZE, COLOR_CRTC,
CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
/* DCC_CGA80 */
{ 0, KD_CGA, "cga", 0, 0, V_ADP_COLOR, IO_CGA, IO_CGASIZE, COLOR_CRTC,
CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
/* DCC_EGAMONO */
{ 0, KD_EGA, "ega", 0, 0, 0, IO_MDA, 48, MONO_CRTC,
EGA_BUF_BASE, EGA_BUF_SIZE, MDA_BUF_BASE, MDA_BUF_SIZE, MDA_BUF_SIZE,
0, 0, 0, 7, 0, 0, NULL },
0, 0, 0, 7, 0, },
/* DCC_EGA40 */
{ 0, KD_EGA, "ega", 0, 0, V_ADP_COLOR, IO_MDA, 48, COLOR_CRTC,
EGA_BUF_BASE, EGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
/* DCC_EGA80 */
{ 0, KD_EGA, "ega", 0, 0, V_ADP_COLOR, IO_MDA, 48, COLOR_CRTC,
EGA_BUF_BASE, EGA_BUF_SIZE, CGA_BUF_BASE, CGA_BUF_SIZE, CGA_BUF_SIZE,
0, 0, 0, 3, 0, 0, NULL },
0, 0, 0, 3, 0, },
};
static video_adapter_t biosadapter[2];
@ -490,6 +490,7 @@ static u_char *get_mode_param(int mode);
static void fill_adapter_param(int code, video_adapter_t *adp);
#endif
static int verify_adapter(video_adapter_t *adp);
static void update_adapter_info(video_adapter_t *adp, video_info_t *info);
#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
#define COMP_IDENTICAL 0
#define COMP_SIMILAR 1
@ -832,6 +833,31 @@ verify_adapter(video_adapter_t *adp)
return 0;
}
static void
update_adapter_info(video_adapter_t *adp, video_info_t *info)
{
adp->va_flags &= ~V_ADP_COLOR;
adp->va_flags |=
(info->vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
adp->va_crtc_addr =
(adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
adp->va_window = BIOS_PADDRTOVADDR(info->vi_window);
adp->va_window_size = info->vi_window_size;
adp->va_window_gran = info->vi_window_gran;
if (info->vi_buffer_size == 0) {
adp->va_buffer = 0;
adp->va_buffer_size = 0;
} else {
adp->va_buffer = BIOS_PADDRTOVADDR(info->vi_buffer);
adp->va_buffer_size = info->vi_buffer_size;
}
if (info->vi_flags & V_INFO_GRAPHICS)
adp->va_line_width = info->vi_width/8;
else
adp->va_line_width = info->vi_width;
bcopy(info, &adp->va_info, sizeof(adp->va_info));
}
#if !defined(VGA_NO_BIOS) && !defined(VGA_NO_MODE_CHANGE)
/* compare two parameter table entries */
static int
@ -977,10 +1003,6 @@ probe_adapters(void)
}
if (biosadapters == 0)
return biosadapters;
#if 0
biosadapter[V_ADP_PRIMARY].va_index = V_ADP_PRIMARY;
biosadapter[V_ADP_SECONDARY].va_index = V_ADP_SECONDARY;
#endif
biosadapter[V_ADP_PRIMARY].va_unit = V_ADP_PRIMARY;
biosadapter[V_ADP_SECONDARY].va_unit = V_ADP_SECONDARY;
@ -1145,35 +1167,12 @@ probe_adapters(void)
/* buffer address */
vga_get_info(&biosadapter[V_ADP_PRIMARY],
biosadapter[V_ADP_PRIMARY].va_initial_mode, &info);
biosadapter[V_ADP_PRIMARY].va_mode_flags = info.vi_flags;
biosadapter[V_ADP_PRIMARY].va_window = BIOS_PADDRTOVADDR(info.vi_window);
biosadapter[V_ADP_PRIMARY].va_window_size = info.vi_window_size;
biosadapter[V_ADP_PRIMARY].va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
biosadapter[V_ADP_PRIMARY].va_buffer = 0;
biosadapter[V_ADP_PRIMARY].va_buffer_size = 0;
} else {
biosadapter[V_ADP_PRIMARY].va_buffer
= BIOS_PADDRTOVADDR(info.vi_buffer);
biosadapter[V_ADP_PRIMARY].va_buffer_size = info.vi_buffer_size;
}
update_adapter_info(&biosadapter[V_ADP_PRIMARY], &info);
if (biosadapters > 1) {
vga_get_info(&biosadapter[V_ADP_SECONDARY],
biosadapter[V_ADP_SECONDARY].va_initial_mode, &info);
biosadapter[V_ADP_SECONDARY].va_mode_flags = info.vi_flags;
biosadapter[V_ADP_SECONDARY].va_window =
BIOS_PADDRTOVADDR(info.vi_window);
biosadapter[V_ADP_SECONDARY].va_window_size = info.vi_window_size;
biosadapter[V_ADP_SECONDARY].va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
biosadapter[V_ADP_SECONDARY].va_buffer = 0;
biosadapter[V_ADP_SECONDARY].va_buffer_size = 0;
} else {
biosadapter[V_ADP_SECONDARY].va_buffer =
BIOS_PADDRTOVADDR(info.vi_buffer);
biosadapter[V_ADP_SECONDARY].va_buffer_size = info.vi_buffer_size;
}
update_adapter_info(&biosadapter[V_ADP_SECONDARY], &info);
}
/*
@ -1429,22 +1428,7 @@ vga_set_mode(video_adapter_t *adp, int mode)
}
adp->va_mode = mode;
adp->va_mode_flags = info.vi_flags;
adp->va_flags &= ~V_ADP_COLOR;
adp->va_flags |=
(info.vi_flags & V_INFO_COLOR) ? V_ADP_COLOR : 0;
adp->va_crtc_addr =
(adp->va_flags & V_ADP_COLOR) ? COLOR_CRTC : MONO_CRTC;
adp->va_window = BIOS_PADDRTOVADDR(info.vi_window);
adp->va_window_size = info.vi_window_size;
adp->va_window_gran = info.vi_window_gran;
if (info.vi_buffer_size == 0) {
adp->va_buffer = 0;
adp->va_buffer_size = 0;
} else {
adp->va_buffer = BIOS_PADDRTOVADDR(info.vi_buffer);
adp->va_buffer_size = info.vi_buffer_size;
}
update_adapter_info(adp, &info);
/* move hardware cursor out of the way */
(*vidsw[adp->va_index]->set_hw_cursor)(adp, -1, -1);
@ -2010,15 +1994,13 @@ vga_set_origin(video_adapter_t *adp, off_t offset)
static int
vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
{
video_info_t info;
u_int16_t off;
int s;
if (!init_done)
return 1;
(*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info);
if (info.vi_flags & V_INFO_GRAPHICS)
if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
return 1;
s = spltty();
@ -2028,8 +2010,8 @@ vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
off = (off << 8) | inb(adp->va_crtc_addr + 1);
splx(s);
*row = off / info.vi_width;
*col = off % info.vi_width;
*row = off / adp->va_info.vi_width;
*col = off % adp->va_info.vi_width;
return 0;
}
@ -2044,7 +2026,6 @@ vga_read_hw_cursor(video_adapter_t *adp, int *col, int *row)
static int
vga_set_hw_cursor(video_adapter_t *adp, int col, int row)
{
video_info_t info;
u_int16_t off;
int s;
@ -2054,10 +2035,9 @@ vga_set_hw_cursor(video_adapter_t *adp, int col, int row)
if ((col == -1) && (row == -1)) {
off = -1;
} else {
(*vidsw[adp->va_index]->get_info)(adp, adp->va_mode, &info);
if (info.vi_flags & V_INFO_GRAPHICS)
if (adp->va_info.vi_flags & V_INFO_GRAPHICS)
return 1;
off = row*info.vi_width + col;
off = row*adp->va_info.vi_width + col;
}
s = spltty();

View File

@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: splash_bmp.c,v 1.4 1999/01/21 18:29:33 yokota Exp $
* $Id: splash_bmp.c,v 1.5 1999/01/26 10:00:02 yokota Exp $
*/
#include <sys/param.h>
@ -216,14 +216,14 @@ fill(BMP_INFO *info, int x, int y, int xsize, int ysize)
int p;
banksize = info->adp->va_window_size;
bank = (info->swidth*y + x)/banksize;
bank = (info->adp->va_line_width*y + x)/banksize;
window = (u_char *)info->adp->va_window;
(*vidsw[info->adp->va_index]->set_win_org)(info->adp, bank*banksize);
while (ysize > 0) {
p = (info->swidth*y + x)%banksize;
p = (info->adp->va_line_width*y + x)%banksize;
for (; (p + xsize <= banksize) && ysize > 0; --ysize, ++y) {
generic_bzero(window + p, xsize);
p += info->swidth;
p += info->adp->va_line_width;
}
if (ysize <= 0)
break;
@ -267,11 +267,11 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
* because 0,0 is bottom-left for DIB, we have to convert.
*/
sofs = ((info->height - (y+1) + (info->sheight - info->height) / 2)
* info->swidth) + x + (info->swidth - info->width) / 2;
* info->adp->va_line_width);
switch(info->sdepth) {
case 1:
sofs = sofs >> 3; /* correct for depth */
sofs += ((x + (info->swidth - info->width) / 2) >> 3);
bofs = x & 0x7; /* offset within byte */
val &= 1; /* mask pixel value */
@ -282,7 +282,7 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
/* XXX only correct for non-interleaved modes */
case 4:
sofs = sofs >> 1; /* correct for depth */
sofs += ((x + (info->swidth - info->width) / 2) >> 1);
bofs = x & 0x1; /* offset within byte */
val &= 0xf; /* mask pixel value */
@ -292,6 +292,7 @@ bmp_SetPix(BMP_INFO *info, int x, int y, u_char val)
break;
case 8:
sofs += x + (info->swidth - info->width) / 2;
newbank = sofs/info->adp->va_window_size;
if (info->bank != newbank) {
(*vidsw[info->adp->va_index]->set_win_org)(info->adp, newbank*info->adp->va_window_size);