Home | History | Annotate | Line # | Download | only in ic
vgavar.h revision 1.6.2.1
      1  1.6.2.1   nathanw /* $NetBSD: vgavar.h,v 1.6.2.1 2001/09/21 22:35:45 nathanw Exp $ */
      2      1.1  drochner 
      3      1.1  drochner /*
      4      1.1  drochner  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5      1.1  drochner  * All rights reserved.
      6      1.1  drochner  *
      7      1.1  drochner  * Author: Chris G. Demetriou
      8      1.1  drochner  *
      9      1.1  drochner  * Permission to use, copy, modify and distribute this software and
     10      1.1  drochner  * its documentation is hereby granted, provided that both the copyright
     11      1.1  drochner  * notice and this permission notice appear in all copies of the
     12      1.1  drochner  * software, derivative works or modified versions, and any portions
     13      1.1  drochner  * thereof, and that both notices appear in supporting documentation.
     14      1.1  drochner  *
     15      1.1  drochner  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16      1.1  drochner  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17      1.1  drochner  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18      1.1  drochner  *
     19      1.1  drochner  * Carnegie Mellon requests users of this software to return to
     20      1.1  drochner  *
     21      1.1  drochner  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22      1.1  drochner  *  School of Computer Science
     23      1.1  drochner  *  Carnegie Mellon University
     24      1.1  drochner  *  Pittsburgh PA 15213-3890
     25      1.1  drochner  *
     26      1.1  drochner  * any improvements or extensions that they make and grant Carnegie the
     27      1.1  drochner  * rights to redistribute these changes.
     28      1.1  drochner  */
     29      1.1  drochner 
     30  1.6.2.1   nathanw #include <sys/callout.h>
     31  1.6.2.1   nathanw 
     32      1.1  drochner struct vga_handle {
     33      1.2  drochner 	struct pcdisplay_handle vh_ph;
     34      1.2  drochner 	bus_space_handle_t vh_ioh_vga, vh_allmemh;
     35      1.2  drochner 	int vh_mono;
     36      1.1  drochner };
     37      1.2  drochner #define vh_iot vh_ph.ph_iot
     38      1.2  drochner #define vh_memt vh_ph.ph_memt
     39      1.2  drochner #define vh_ioh_6845 vh_ph.ph_ioh_6845
     40      1.2  drochner #define vh_memh vh_ph.ph_memh
     41      1.1  drochner 
     42  1.6.2.1   nathanw struct vga_funcs {
     43  1.6.2.1   nathanw 	int (*vf_ioctl)(void *, u_long, caddr_t, int, struct proc *);
     44  1.6.2.1   nathanw 	paddr_t (*vf_mmap)(void *, off_t, int);
     45  1.6.2.1   nathanw };
     46  1.6.2.1   nathanw 
     47  1.6.2.1   nathanw struct vga_config {
     48  1.6.2.1   nathanw 	struct vga_handle hdl;
     49  1.6.2.1   nathanw 	struct vga_softc *softc;
     50  1.6.2.1   nathanw 
     51  1.6.2.1   nathanw 	int nscreens;
     52  1.6.2.1   nathanw 	LIST_HEAD(, vgascreen) screens;
     53  1.6.2.1   nathanw 	struct vgascreen *active; /* current display */
     54  1.6.2.1   nathanw 	const struct wsscreen_descr *currenttype;
     55  1.6.2.1   nathanw 	int currentfontset1, currentfontset2;
     56  1.6.2.1   nathanw 
     57  1.6.2.1   nathanw 	int vc_biosmapped;
     58  1.6.2.1   nathanw 	bus_space_tag_t vc_biostag;
     59  1.6.2.1   nathanw 	bus_space_handle_t vc_bioshdl;
     60  1.6.2.1   nathanw 
     61  1.6.2.1   nathanw 	struct egavga_font *vc_fonts[8]; /* currently loaded */
     62  1.6.2.1   nathanw 	TAILQ_HEAD(, egavga_font) vc_fontlist; /* LRU queue */
     63  1.6.2.1   nathanw 
     64  1.6.2.1   nathanw 	struct vgascreen *wantedscreen;
     65  1.6.2.1   nathanw 	void (*switchcb) __P((void *, int, int));
     66  1.6.2.1   nathanw 	void *switchcbarg;
     67  1.6.2.1   nathanw 
     68  1.6.2.1   nathanw 	int vc_type;
     69  1.6.2.1   nathanw 	const struct vga_funcs *vc_funcs;
     70  1.6.2.1   nathanw 
     71  1.6.2.1   nathanw 	struct callout vc_switch_callout;
     72  1.6.2.1   nathanw };
     73  1.6.2.1   nathanw 
     74  1.6.2.1   nathanw struct vga_softc {
     75  1.6.2.1   nathanw 	struct device sc_dev;
     76  1.6.2.1   nathanw 	struct vga_config *sc_vc;
     77  1.6.2.1   nathanw };
     78  1.6.2.1   nathanw 
     79      1.1  drochner static inline u_int8_t _vga_attr_read __P((struct vga_handle *, int));
     80      1.1  drochner static inline void _vga_attr_write __P((struct vga_handle *, int, u_int8_t));
     81      1.1  drochner static inline u_int8_t _vga_ts_read __P((struct vga_handle *, int));
     82      1.1  drochner static inline void _vga_ts_write __P((struct vga_handle *, int, u_int8_t));
     83      1.1  drochner static inline u_int8_t _vga_gdc_read __P((struct vga_handle *, int));
     84      1.1  drochner static inline void _vga_gdc_write __P((struct vga_handle *, int, u_int8_t));
     85      1.1  drochner 
     86      1.1  drochner static inline u_int8_t _vga_attr_read(vh, reg)
     87      1.1  drochner 	struct vga_handle *vh;
     88      1.1  drochner 	int reg;
     89      1.1  drochner {
     90      1.1  drochner 	u_int8_t res;
     91      1.1  drochner 
     92      1.1  drochner 	/* reset state */
     93      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     94      1.1  drochner 
     95      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
     96      1.1  drochner 	res = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAR);
     97      1.1  drochner 
     98      1.1  drochner 	/* reset state XXX unneeded? */
     99      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
    100      1.1  drochner 
    101      1.1  drochner 	/* enable */
    102      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
    103      1.1  drochner 
    104      1.1  drochner 	return (res);
    105      1.1  drochner }
    106      1.1  drochner 
    107      1.1  drochner static inline void _vga_attr_write(vh, reg, val)
    108      1.1  drochner 	struct vga_handle *vh;
    109      1.1  drochner 	int reg;
    110      1.1  drochner 	u_int8_t val;
    111      1.1  drochner {
    112      1.1  drochner 	/* reset state */
    113      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
    114      1.1  drochner 
    115      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
    116      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAW, val);
    117      1.1  drochner 
    118      1.1  drochner 	/* reset state XXX unneeded? */
    119      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
    120      1.1  drochner 
    121      1.1  drochner 	/* enable */
    122      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
    123      1.1  drochner }
    124      1.1  drochner 
    125      1.1  drochner static inline u_int8_t _vga_ts_read(vh, reg)
    126      1.1  drochner 	struct vga_handle *vh;
    127      1.1  drochner 	int reg;
    128      1.1  drochner {
    129      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
    130      1.1  drochner 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA));
    131      1.1  drochner }
    132      1.1  drochner 
    133      1.1  drochner static inline void _vga_ts_write(vh, reg, val)
    134      1.1  drochner 	struct vga_handle *vh;
    135      1.1  drochner 	int reg;
    136      1.1  drochner 	u_int8_t val;
    137      1.1  drochner {
    138      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
    139      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA, val);
    140      1.1  drochner }
    141      1.1  drochner 
    142      1.1  drochner static inline u_int8_t _vga_gdc_read(vh, reg)
    143      1.1  drochner 	struct vga_handle *vh;
    144      1.1  drochner 	int reg;
    145      1.1  drochner {
    146      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
    147      1.1  drochner 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA));
    148      1.1  drochner }
    149      1.1  drochner 
    150      1.1  drochner static inline void _vga_gdc_write(vh, reg, val)
    151      1.1  drochner 	struct vga_handle *vh;
    152      1.1  drochner 	int reg;
    153      1.1  drochner 	u_int8_t val;
    154      1.1  drochner {
    155      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
    156      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA, val);
    157      1.1  drochner }
    158      1.1  drochner 
    159      1.1  drochner #define vga_attr_read(vh, reg) \
    160      1.1  drochner 	_vga_attr_read(vh, offsetof(struct reg_vgaattr, reg))
    161      1.1  drochner #define vga_attr_write(vh, reg, val) \
    162      1.1  drochner 	_vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val)
    163      1.1  drochner #define vga_ts_read(vh, reg) \
    164      1.1  drochner 	_vga_ts_read(vh, offsetof(struct reg_vgats, reg))
    165      1.1  drochner #define vga_ts_write(vh, reg, val) \
    166      1.1  drochner 	_vga_ts_write(vh, offsetof(struct reg_vgats, reg), val)
    167      1.1  drochner #define vga_gdc_read(vh, reg) \
    168      1.1  drochner 	_vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg))
    169      1.1  drochner #define vga_gdc_write(vh, reg, val) \
    170      1.1  drochner 	_vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val)
    171      1.1  drochner 
    172      1.2  drochner #define vga_6845_read(vh, reg) \
    173      1.2  drochner 	pcdisplay_6845_read(&(vh)->vh_ph, reg)
    174      1.2  drochner #define vga_6845_write(vh, reg, val) \
    175      1.2  drochner 	pcdisplay_6845_write(&(vh)->vh_ph, reg, val)
    176      1.1  drochner 
    177      1.1  drochner int	vga_common_probe __P((bus_space_tag_t, bus_space_tag_t));
    178  1.6.2.1   nathanw void	vga_common_attach __P((struct vga_softc *, bus_space_tag_t,
    179      1.6   thorpej 			       bus_space_tag_t, int,
    180  1.6.2.1   nathanw 			       const struct vga_funcs *));
    181      1.1  drochner int	vga_is_console __P((bus_space_tag_t, int));
    182      1.1  drochner 
    183      1.1  drochner int	vga_cnattach __P((bus_space_tag_t, bus_space_tag_t, int, int));
    184      1.1  drochner 
    185      1.1  drochner struct wsscreen_descr;
    186      1.1  drochner void vga_loadchars __P((struct vga_handle *, int, int, int, int, char *));
    187      1.3  drochner void vga_setfontset __P((struct vga_handle *, int, int));
    188      1.1  drochner void vga_setscreentype __P((struct vga_handle *,
    189      1.1  drochner 			    const struct wsscreen_descr *));
    190