move probe and setup code into common functions. always probe (i.e.
even if PCI and the IDs are right), just for sanity, before declaring success. Split the single 0x3b0 -> 0x3df allocation into three seperate ones: 0x3b0 -> 0x3bc (leaving the 4 ports available for lpt), 0x3c0 -> 0x3cf, and 0x3d0 -> 0x3df. The former chunk has to be split off if the lpt can exist there, and it's sort-of pretty to have each group (based on second hex digit) have its own handle.
This commit is contained in:
parent
ae3ad75501
commit
335c1af878
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vga.c,v 1.1 1996/11/19 04:38:32 cgd Exp $ */
|
/* $NetBSD: vga.c,v 1.2 1996/11/23 06:06:43 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||||
|
@ -36,8 +36,8 @@
|
||||||
#include <alpha/wscons/wsconsvar.h>
|
#include <alpha/wscons/wsconsvar.h>
|
||||||
#include <alpha/common/vgavar.h>
|
#include <alpha/common/vgavar.h>
|
||||||
|
|
||||||
#define VGA_6845_ADDR 0x24
|
#define VGA_IO_D_6845_ADDR 0x4
|
||||||
#define VGA_6845_DATA 0x25
|
#define VGA_IO_D_6845_DATA 0x5
|
||||||
|
|
||||||
struct cfdriver vga_cd = {
|
struct cfdriver vga_cd = {
|
||||||
NULL, "vga", DV_DULL,
|
NULL, "vga", DV_DULL,
|
||||||
|
@ -67,24 +67,73 @@ static int vgammap __P((void *, off_t, int));
|
||||||
* The following functions implement back-end configuration grabbing
|
* The following functions implement back-end configuration grabbing
|
||||||
* and attachment.
|
* and attachment.
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
|
vga_common_probe(iot, memt)
|
||||||
|
bus_space_tag_t iot, memt;
|
||||||
|
{
|
||||||
|
bus_space_handle_t ioh_b, ioh_c, ioh_d, memh;
|
||||||
|
u_int16_t vgadata;
|
||||||
|
int gotio_b, gotio_c, gotio_d, gotmem, rv;
|
||||||
|
|
||||||
|
gotio_b = gotio_c = gotio_d = gotmem = rv = 0;
|
||||||
|
|
||||||
|
if (bus_space_map(iot, 0x3b0, 0xc, 0, &ioh_b))
|
||||||
|
goto bad;
|
||||||
|
gotio_b = 1;
|
||||||
|
if (bus_space_map(iot, 0x3c0, 0x10, 0, &ioh_c))
|
||||||
|
goto bad;
|
||||||
|
gotio_c = 1;
|
||||||
|
if (bus_space_map(iot, 0x3d0, 0x10, 0, &ioh_d))
|
||||||
|
goto bad;
|
||||||
|
gotio_d = 1;
|
||||||
|
if (bus_space_map(memt, 0xb8000, 0x8000, 0, &memh))
|
||||||
|
goto bad;
|
||||||
|
gotmem = 1;
|
||||||
|
|
||||||
|
vgadata = bus_space_read_2(memt, memh, 0);
|
||||||
|
bus_space_write_2(memt, memh, 0, 0xa55a);
|
||||||
|
rv = (bus_space_read_2(memt, memh, 0) == 0xa55a);
|
||||||
|
bus_space_write_2(memt, memh, 0, vgadata);
|
||||||
|
|
||||||
|
bad:
|
||||||
|
if (gotio_b)
|
||||||
|
bus_space_unmap(iot, ioh_b, 0xc);
|
||||||
|
if (gotio_c)
|
||||||
|
bus_space_unmap(iot, ioh_c, 0x10);
|
||||||
|
if (gotio_d)
|
||||||
|
bus_space_unmap(iot, ioh_d, 0x10);
|
||||||
|
if (gotmem)
|
||||||
|
bus_space_unmap(memt, memh, 0x8000);
|
||||||
|
|
||||||
|
return (rv);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vga_getconfig(vc)
|
vga_common_setup(iot, memt, vc)
|
||||||
|
bus_space_tag_t iot, memt;
|
||||||
struct vga_config *vc;
|
struct vga_config *vc;
|
||||||
{
|
{
|
||||||
bus_space_tag_t iot;
|
|
||||||
bus_space_handle_t ioh;
|
|
||||||
int cpos;
|
int cpos;
|
||||||
|
|
||||||
iot = vc->vc_iot;
|
vc->vc_iot = iot;
|
||||||
ioh = vc->vc_ioh;
|
vc->vc_memt = memt;
|
||||||
|
|
||||||
|
if (bus_space_map(vc->vc_iot, 0x3b0, 0xc, 0, &vc->vc_ioh_b))
|
||||||
|
panic("vga_common_setup: couldn't map io b");
|
||||||
|
if (bus_space_map(vc->vc_iot, 0x3c0, 0x10, 0, &vc->vc_ioh_c))
|
||||||
|
panic("vga_common_setup: couldn't map io c");
|
||||||
|
if (bus_space_map(vc->vc_iot, 0x3d0, 0x10, 0, &vc->vc_ioh_d))
|
||||||
|
panic("vga_common_setup: couldn't map io d");
|
||||||
|
if (bus_space_map(vc->vc_memt, 0xb8000, 0x8000, 0, &vc->vc_memh))
|
||||||
|
panic("vga_common_setup: couldn't map memory");
|
||||||
|
|
||||||
vc->vc_nrow = 25;
|
vc->vc_nrow = 25;
|
||||||
vc->vc_ncol = 80;
|
vc->vc_ncol = 80;
|
||||||
|
|
||||||
bus_space_write_1(iot, ioh, VGA_6845_ADDR, 14);
|
bus_space_write_1(iot, vc->vc_ioh_d, VGA_IO_D_6845_ADDR, 14);
|
||||||
cpos = bus_space_read_1(iot, ioh, VGA_6845_DATA) << 8;
|
cpos = bus_space_read_1(iot, vc->vc_ioh_d, VGA_IO_D_6845_DATA) << 8;
|
||||||
bus_space_write_1(iot, ioh, VGA_6845_ADDR, 15);
|
bus_space_write_1(iot, vc->vc_ioh_d, VGA_IO_D_6845_ADDR, 15);
|
||||||
cpos |= bus_space_read_1(iot, ioh, VGA_6845_DATA);
|
cpos |= bus_space_read_1(iot, vc->vc_ioh_d, VGA_IO_D_6845_DATA);
|
||||||
vc->vc_crow = cpos / vc->vc_ncol;
|
vc->vc_crow = cpos / vc->vc_ncol;
|
||||||
vc->vc_ccol = cpos % vc->vc_ncol;
|
vc->vc_ccol = cpos % vc->vc_ncol;
|
||||||
|
|
||||||
|
@ -197,7 +246,7 @@ vga_cursor(id, on, row, col)
|
||||||
{
|
{
|
||||||
struct vga_config *vc = id;
|
struct vga_config *vc = id;
|
||||||
bus_space_tag_t iot = vc->vc_iot;
|
bus_space_tag_t iot = vc->vc_iot;
|
||||||
bus_space_handle_t ioh = vc->vc_ioh;
|
bus_space_handle_t ioh_d = vc->vc_ioh_d;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -214,10 +263,10 @@ vga_cursor(id, on, row, col)
|
||||||
|
|
||||||
pos = row * vc->vc_ncol + col;
|
pos = row * vc->vc_ncol + col;
|
||||||
|
|
||||||
bus_space_write_1(iot, ioh, VGA_6845_ADDR, 14);
|
bus_space_write_1(iot, ioh_d, VGA_IO_D_6845_ADDR, 14);
|
||||||
bus_space_write_1(iot, ioh, VGA_6845_DATA, pos >> 8);
|
bus_space_write_1(iot, ioh_d, VGA_IO_D_6845_DATA, pos >> 8);
|
||||||
bus_space_write_1(iot, ioh, VGA_6845_ADDR, 15);
|
bus_space_write_1(iot, ioh_d, VGA_IO_D_6845_ADDR, 15);
|
||||||
bus_space_write_1(iot, ioh, VGA_6845_DATA, pos);
|
bus_space_write_1(iot, ioh_d, VGA_IO_D_6845_DATA, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vgavar.h,v 1.1 1996/11/19 04:38:33 cgd Exp $ */
|
/* $NetBSD: vgavar.h,v 1.2 1996/11/23 06:06:43 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||||
|
@ -32,7 +32,7 @@ struct vga_config {
|
||||||
* Filled in by front-ends.
|
* Filled in by front-ends.
|
||||||
*/
|
*/
|
||||||
bus_space_tag_t vc_iot, vc_memt;
|
bus_space_tag_t vc_iot, vc_memt;
|
||||||
bus_space_handle_t vc_ioh, vc_memh;
|
bus_space_handle_t vc_ioh_b, vc_ioh_c, vc_ioh_d, vc_memh;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private to back-end.
|
* Private to back-end.
|
||||||
|
@ -45,6 +45,8 @@ struct vga_config {
|
||||||
char vc_so_at; /* standout attributes */
|
char vc_so_at; /* standout attributes */
|
||||||
};
|
};
|
||||||
|
|
||||||
void vga_getconfig __P((struct vga_config *));
|
int vga_common_probe __P((bus_space_tag_t, bus_space_tag_t));
|
||||||
|
void vga_common_setup __P((bus_space_tag_t, bus_space_tag_t,
|
||||||
|
struct vga_config *));
|
||||||
void vga_wscons_attach __P((struct device *, struct vga_config *, int));
|
void vga_wscons_attach __P((struct device *, struct vga_config *, int));
|
||||||
void vga_wscons_console __P((struct vga_config *));
|
void vga_wscons_console __P((struct vga_config *));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vga_isa.c,v 1.2 1996/11/20 20:04:53 cgd Exp $ */
|
/* $NetBSD: vga_isa.c,v 1.3 1996/11/23 06:06:44 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||||
|
@ -57,37 +57,6 @@ struct cfattach vga_isa_ca = {
|
||||||
int vga_isa_console_tag; /* really just a boolean. */
|
int vga_isa_console_tag; /* really just a boolean. */
|
||||||
struct vga_config vga_isa_console_vc;
|
struct vga_config vga_isa_console_vc;
|
||||||
|
|
||||||
int
|
|
||||||
vga_isa_probe(iot, memt)
|
|
||||||
bus_space_tag_t iot, memt;
|
|
||||||
{
|
|
||||||
bus_space_handle_t ioh, memh;
|
|
||||||
u_int16_t vgadata;
|
|
||||||
int gotio, gotmem, rv;
|
|
||||||
|
|
||||||
gotio = gotmem = rv = 0;
|
|
||||||
|
|
||||||
if (bus_space_map(iot, 0x3b0, 0x30, 0, &ioh))
|
|
||||||
goto bad;
|
|
||||||
gotio = 1;
|
|
||||||
if (bus_space_map(memt, 0xb8000, 0x8000, 0, &memh))
|
|
||||||
goto bad;
|
|
||||||
gotmem = 1;
|
|
||||||
|
|
||||||
vgadata = bus_space_read_2(memt, memh, 0);
|
|
||||||
bus_space_write_2(memt, memh, 0, 0xa55a);
|
|
||||||
rv = (bus_space_read_2(memt, memh, 0) == 0xa55a);
|
|
||||||
bus_space_write_2(memt, memh, 0, vgadata);
|
|
||||||
|
|
||||||
bad:
|
|
||||||
if (gotmem)
|
|
||||||
bus_space_unmap(memt, memh, 0x8000);
|
|
||||||
if (gotio)
|
|
||||||
bus_space_unmap(iot, ioh, 0x30);
|
|
||||||
|
|
||||||
return (rv);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
vga_isa_match(parent, match, aux)
|
vga_isa_match(parent, match, aux)
|
||||||
struct device *parent;
|
struct device *parent;
|
||||||
|
@ -97,8 +66,7 @@ vga_isa_match(parent, match, aux)
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
/* If values are hardwired to something that they can't be, punt. */
|
/* If values are hardwired to something that they can't be, punt. */
|
||||||
if ((ia->ia_iobase != IOBASEUNK && ia->ia_iobase != 0x3b0) ||
|
if (ia->ia_iobase != IOBASEUNK || /* ia->ia_iosize != 0 || XXX isa.c */
|
||||||
/* (ia->ia_iosize != 0 && ia->ia_iosize != 0x30) || XXX isa.c */
|
|
||||||
(ia->ia_maddr != MADDRUNK && ia->ia_maddr != 0xb8000) ||
|
(ia->ia_maddr != MADDRUNK && ia->ia_maddr != 0xb8000) ||
|
||||||
(ia->ia_msize != 0 && ia->ia_msize != 0x8000) ||
|
(ia->ia_msize != 0 && ia->ia_msize != 0x8000) ||
|
||||||
ia->ia_irq != IRQUNK || ia->ia_drq != DRQUNK)
|
ia->ia_irq != IRQUNK || ia->ia_drq != DRQUNK)
|
||||||
|
@ -107,7 +75,7 @@ vga_isa_match(parent, match, aux)
|
||||||
if (vga_isa_console_tag)
|
if (vga_isa_console_tag)
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
rv = vga_isa_probe(ia->ia_iot, ia->ia_memt);
|
rv = vga_common_probe(ia->ia_iot, ia->ia_memt);
|
||||||
|
|
||||||
if (rv) {
|
if (rv) {
|
||||||
ia->ia_iobase = 0x3b0;
|
ia->ia_iobase = 0x3b0;
|
||||||
|
@ -135,15 +103,8 @@ vga_isa_attach(parent, self, aux)
|
||||||
vc = sc->sc_vc = (struct vga_config *)
|
vc = sc->sc_vc = (struct vga_config *)
|
||||||
malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK);
|
malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK);
|
||||||
|
|
||||||
/* for bus-independent VGA code */
|
/* set up bus-independent VGA configuration */
|
||||||
vc->vc_iot = ia->ia_iot;
|
vga_common_setup(ia->ia_iot, ia->ia_memt, vc);
|
||||||
vc->vc_memt = ia->ia_memt;
|
|
||||||
if (bus_space_map(vc->vc_iot, 0x3b0, 0x30, 0, &vc->vc_ioh))
|
|
||||||
panic("vga_isa_attach: couldn't map io");
|
|
||||||
if (bus_space_map(vc->vc_memt, 0xb8000, 0x8000, 0,
|
|
||||||
&vc->vc_memh))
|
|
||||||
panic("vga_isa_attach: couldn't map memory");
|
|
||||||
vga_getconfig(vc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -151,8 +112,16 @@ vga_isa_attach(parent, self, aux)
|
||||||
vga_wscons_attach(self, vc, console);
|
vga_wscons_attach(self, vc, console);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
vga_isa_console_match(iot, memt)
|
||||||
|
bus_space_tag_t iot, memt;
|
||||||
|
{
|
||||||
|
|
||||||
|
return (vga_common_probe(iot, memt));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
vga_isa_console(iot, memt)
|
vga_isa_console_attach(iot, memt)
|
||||||
bus_space_tag_t iot, memt;
|
bus_space_tag_t iot, memt;
|
||||||
{
|
{
|
||||||
struct vga_config *vc = &vga_isa_console_vc;
|
struct vga_config *vc = &vga_isa_console_vc;
|
||||||
|
@ -160,14 +129,8 @@ vga_isa_console(iot, memt)
|
||||||
/* for later recognition */
|
/* for later recognition */
|
||||||
vga_isa_console_tag = 1;
|
vga_isa_console_tag = 1;
|
||||||
|
|
||||||
/* for bus-independent VGA code */
|
/* set up bus-independent VGA configuration */
|
||||||
vc->vc_iot = iot;
|
vga_common_setup(iot, memt, vc);
|
||||||
vc->vc_memt = memt;
|
|
||||||
if (bus_space_map(vc->vc_iot, 0x3b0, 0x30, 0, &vc->vc_ioh))
|
|
||||||
panic("vga_isa_console: couldn't map io");
|
|
||||||
if (bus_space_map(vc->vc_memt, 0xb8000, 0x8000, 0, &vc->vc_memh))
|
|
||||||
panic("vga_isa_console: couldn't map memory");
|
|
||||||
vga_getconfig(vc);
|
|
||||||
|
|
||||||
vga_wscons_console(vc);
|
vga_wscons_console(vc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vga_isavar.h,v 1.1 1996/11/19 04:38:34 cgd Exp $ */
|
/* $NetBSD: vga_isavar.h,v 1.2 1996/11/23 06:06:45 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996 Carnegie-Mellon University.
|
* Copyright (c) 1996 Carnegie-Mellon University.
|
||||||
|
@ -27,5 +27,5 @@
|
||||||
* rights to redistribute these changes.
|
* rights to redistribute these changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int vga_isa_probe __P((bus_space_tag_t, bus_space_tag_t));
|
int vga_isa_console_match __P((bus_space_tag_t, bus_space_tag_t));
|
||||||
void vga_isa_console __P((bus_space_tag_t, bus_space_tag_t));
|
void vga_isa_console_attach __P((bus_space_tag_t, bus_space_tag_t));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: vga_pci.c,v 1.1 1996/11/19 04:38:35 cgd Exp $ */
|
/* $NetBSD: vga_pci.c,v 1.2 1996/11/23 06:06:47 cgd Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||||
|
@ -66,18 +66,27 @@ vga_pci_match(parent, match, aux)
|
||||||
void *match, *aux;
|
void *match, *aux;
|
||||||
{
|
{
|
||||||
struct pci_attach_args *pa = aux;
|
struct pci_attach_args *pa = aux;
|
||||||
|
int potential;
|
||||||
|
|
||||||
|
potential = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If it's prehistoric/vga or display/vga, we match.
|
* If it's prehistoric/vga or display/vga, we might match.
|
||||||
*/
|
*/
|
||||||
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_PREHISTORIC &&
|
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_PREHISTORIC &&
|
||||||
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_PREHISTORIC_VGA)
|
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_PREHISTORIC_VGA)
|
||||||
return (1);
|
potential = 1;
|
||||||
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY &&
|
if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY &&
|
||||||
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_DISPLAY_VGA)
|
PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_DISPLAY_VGA)
|
||||||
return (1);
|
potential = 1;
|
||||||
|
|
||||||
return (0);
|
/*
|
||||||
|
* If we might match, make sure that the card actually looks OK.
|
||||||
|
*/
|
||||||
|
if (potential && vga_common_probe(pa->pa_iot, pa->pa_memt) == 0)
|
||||||
|
potential = 0;
|
||||||
|
|
||||||
|
return (potential);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -98,15 +107,8 @@ vga_pci_attach(parent, self, aux)
|
||||||
vc = sc->sc_vc = (struct vga_config *)
|
vc = sc->sc_vc = (struct vga_config *)
|
||||||
malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK);
|
malloc(sizeof(struct vga_config), M_DEVBUF, M_WAITOK);
|
||||||
|
|
||||||
/* for bus-independent VGA code */
|
/* set up bus-independent VGA configuration */
|
||||||
vc->vc_iot = pa->pa_iot;
|
vga_common_setup(pa->pa_iot, pa->pa_memt, vc);
|
||||||
vc->vc_memt = pa->pa_memt;
|
|
||||||
if (bus_space_map(vc->vc_iot, 0x3b0, 0x30, 0, &vc->vc_ioh))
|
|
||||||
panic("vga_pci_attach: couldn't map io");
|
|
||||||
if (bus_space_map(vc->vc_memt, 0xb8000, 0x8000, 0,
|
|
||||||
&vc->vc_memh))
|
|
||||||
panic("vga_pci_attach: couldn't map memory");
|
|
||||||
vga_getconfig(vc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sc->sc_pcitag = pa->pa_tag;
|
sc->sc_pcitag = pa->pa_tag;
|
||||||
|
@ -129,14 +131,8 @@ vga_pci_console(iot, memt, pc, bus, device, function)
|
||||||
/* for later recognition */
|
/* for later recognition */
|
||||||
vga_pci_console_tag = pci_make_tag(pc, bus, device, function);
|
vga_pci_console_tag = pci_make_tag(pc, bus, device, function);
|
||||||
|
|
||||||
/* for bus-independent VGA code */
|
/* set up bus-independent VGA configuration */
|
||||||
vc->vc_iot = iot;
|
vga_common_setup(iot, memt, vc);
|
||||||
vc->vc_memt = memt;
|
|
||||||
if (bus_space_map(vc->vc_iot, 0x3b0, 0x30, 0, &vc->vc_ioh))
|
|
||||||
panic("vga_pci_console: couldn't map io");
|
|
||||||
if (bus_space_map(vc->vc_memt, 0xb8000, 0x8000, 0, &vc->vc_memh))
|
|
||||||
panic("vga_pci_console: couldn't map memory");
|
|
||||||
vga_getconfig(vc);
|
|
||||||
|
|
||||||
vga_wscons_console(vc);
|
vga_wscons_console(vc);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue