diff options
| author | junyoung <junyoung@NetBSD.org> | 2002-10-15 17:30:43 +0000 |
|---|---|---|
| committer | junyoung <junyoung@NetBSD.org> | 2002-10-15 17:30:43 +0000 |
| commit | 0f061c7c7a88ce29a4746e8dee761f0edeaa9d68 (patch) | |
| tree | 7e35bc59a2cd7a343be78863fa0d6b4dfcd4bef8 /sys/dev | |
| parent | ca541391bc515acbf5ed4f03d9580167752cdea8 (diff) | |
Move vga_common_probe() to vga_common.c. vga_common.c contains common
stuff between existing char-cell VGA driver and raster VGA driver to
come shortly.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/ic/vga.c | 75 | ||||
| -rw-r--r-- | sys/dev/ic/vga_common.c | 108 |
2 files changed, 110 insertions, 73 deletions
diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c index 8587a9fd3b1..16e503b50cb 100644 --- a/sys/dev/ic/vga.c +++ b/sys/dev/ic/vga.c @@ -1,4 +1,4 @@ -/* $NetBSD: vga.c,v 1.63 2002/07/08 19:45:28 drochner Exp $ */ +/* $NetBSD: vga.c,v 1.64 2002/10/15 17:30:43 junyoung Exp $ */ /* * Copyright (c) 1995, 1996 Carnegie-Mellon University. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.63 2002/07/08 19:45:28 drochner Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vga.c,v 1.64 2002/10/15 17:30:43 junyoung Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -273,77 +273,6 @@ const struct wsdisplay_accessops vga_accessops = { }; /* - * The following functions implement back-end configuration grabbing - * and attachment. - */ -int -vga_common_probe(bus_space_tag_t iot, bus_space_tag_t memt) -{ - bus_space_handle_t ioh_vga, ioh_6845, memh; - u_int8_t regval; - u_int16_t vgadata; - int gotio_vga, gotio_6845, gotmem, mono, rv; - int dispoffset; - - gotio_vga = gotio_6845 = gotmem = rv = 0; - - if (bus_space_map(iot, 0x3c0, 0x10, 0, &ioh_vga)) - goto bad; - gotio_vga = 1; - - /* read "misc output register" */ - regval = bus_space_read_1(iot, ioh_vga, 0xc); - mono = !(regval & 1); - - if (bus_space_map(iot, (mono ? 0x3b0 : 0x3d0), 0x10, 0, &ioh_6845)) - goto bad; - gotio_6845 = 1; - - if (bus_space_map(memt, 0xa0000, 0x20000, 0, &memh)) - goto bad; - gotmem = 1; - - dispoffset = (mono ? 0x10000 : 0x18000); - - vgadata = bus_space_read_2(memt, memh, dispoffset); - bus_space_write_2(memt, memh, dispoffset, 0xa55a); - if (bus_space_read_2(memt, memh, dispoffset) != 0xa55a) - goto bad; - bus_space_write_2(memt, memh, dispoffset, vgadata); - - /* - * check if this is really a VGA - * (try to write "Color Select" register as XFree86 does) - * XXX check before if at least EGA? - */ - /* reset state */ - (void) bus_space_read_1(iot, ioh_6845, 10); - bus_space_write_1(iot, ioh_vga, VGA_ATC_INDEX, - 20 | 0x20); /* colselect | enable */ - regval = bus_space_read_1(iot, ioh_vga, VGA_ATC_DATAR); - /* toggle the implemented bits */ - bus_space_write_1(iot, ioh_vga, VGA_ATC_DATAW, regval ^ 0x0f); - bus_space_write_1(iot, ioh_vga, VGA_ATC_INDEX, - 20 | 0x20); - /* read back */ - if (bus_space_read_1(iot, ioh_vga, VGA_ATC_DATAR) != (regval ^ 0x0f)) - goto bad; - /* restore contents */ - bus_space_write_1(iot, ioh_vga, VGA_ATC_DATAW, regval); - - rv = 1; -bad: - if (gotio_vga) - bus_space_unmap(iot, ioh_vga, 0x10); - if (gotio_6845) - bus_space_unmap(iot, ioh_6845, 0x10); - if (gotmem) - bus_space_unmap(memt, memh, 0x20000); - - return (rv); -} - -/* * We want at least ASCII 32..127 be present in the * first font slot. */ diff --git a/sys/dev/ic/vga_common.c b/sys/dev/ic/vga_common.c new file mode 100644 index 00000000000..dd173ee313a --- /dev/null +++ b/sys/dev/ic/vga_common.c @@ -0,0 +1,108 @@ +/* $NetBSD: vga_common.c,v 1.1 2002/10/15 17:30:44 junyoung Exp $ */ + +/* + * Copyright (c) 1995, 1996 Carnegie-Mellon University. + * All rights reserved. + * + * Author: Chris G. Demetriou + * + * Permission to use, copy, modify and distribute this software and + * its documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND + * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie the + * rights to redistribute these changes. + */ + +#include <sys/param.h> +#include <sys/device.h> +#include <machine/bus.h> + +#include <dev/ic/mc6845reg.h> +#include <dev/ic/pcdisplayvar.h> +#include <dev/ic/vgareg.h> +#include <dev/ic/vgavar.h> + +/* + * The following functions implement back-end configuration grabbing + * and attachment. + */ +int +vga_common_probe(bus_space_tag_t iot, bus_space_tag_t memt) +{ + bus_space_handle_t ioh_vga, ioh_6845, memh; + u_int8_t regval; + u_int16_t vgadata; + int gotio_vga, gotio_6845, gotmem, mono, rv; + int dispoffset; + + gotio_vga = gotio_6845 = gotmem = rv = 0; + + if (bus_space_map(iot, 0x3c0, 0x10, 0, &ioh_vga)) + goto bad; + gotio_vga = 1; + + /* read "misc output register" */ + regval = bus_space_read_1(iot, ioh_vga, 0xc); + mono = !(regval & 1); + + if (bus_space_map(iot, (mono ? 0x3b0 : 0x3d0), 0x10, 0, &ioh_6845)) + goto bad; + gotio_6845 = 1; + + if (bus_space_map(memt, 0xa0000, 0x20000, 0, &memh)) + goto bad; + gotmem = 1; + + dispoffset = (mono ? 0x10000 : 0x18000); + + vgadata = bus_space_read_2(memt, memh, dispoffset); + bus_space_write_2(memt, memh, dispoffset, 0xa55a); + if (bus_space_read_2(memt, memh, dispoffset) != 0xa55a) + goto bad; + bus_space_write_2(memt, memh, dispoffset, vgadata); + + /* + * check if this is really a VGA + * (try to write "Color Select" register as XFree86 does) + * XXX check before if at least EGA? + */ + /* reset state */ + (void) bus_space_read_1(iot, ioh_6845, 10); + bus_space_write_1(iot, ioh_vga, VGA_ATC_INDEX, + 20 | 0x20); /* colselect | enable */ + regval = bus_space_read_1(iot, ioh_vga, VGA_ATC_DATAR); + /* toggle the implemented bits */ + bus_space_write_1(iot, ioh_vga, VGA_ATC_DATAW, regval ^ 0x0f); + bus_space_write_1(iot, ioh_vga, VGA_ATC_INDEX, + 20 | 0x20); + /* read back */ + if (bus_space_read_1(iot, ioh_vga, VGA_ATC_DATAR) != (regval ^ 0x0f)) + goto bad; + /* restore contents */ + bus_space_write_1(iot, ioh_vga, VGA_ATC_DATAW, regval); + + rv = 1; +bad: + if (gotio_vga) + bus_space_unmap(iot, ioh_vga, 0x10); + if (gotio_6845) + bus_space_unmap(iot, ioh_6845, 0x10); + if (gotmem) + bus_space_unmap(memt, memh, 0x20000); + + return (rv); +} |
