Home | History | Annotate | Line # | Download | only in ic
vgavar.h revision 1.1
      1 /* $NetBSD: vgavar.h,v 1.1 1998/03/22 15:11:49 drochner Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 
     30 struct vga_handle {
     31 	bus_space_tag_t	vh_iot, vh_memt;
     32 	bus_space_handle_t vh_ioh_vga, vh_ioh_6845, vh_allmemh, vh_memh;
     33 
     34 	int mono; /* flag */
     35 };
     36 
     37 static inline u_int8_t _vga_6845_read __P((struct vga_handle *, int));
     38 static inline void _vga_6845_write __P((struct vga_handle *, int, u_int8_t));
     39 static inline u_int8_t _vga_attr_read __P((struct vga_handle *, int));
     40 static inline void _vga_attr_write __P((struct vga_handle *, int, u_int8_t));
     41 static inline u_int8_t _vga_ts_read __P((struct vga_handle *, int));
     42 static inline void _vga_ts_write __P((struct vga_handle *, int, u_int8_t));
     43 static inline u_int8_t _vga_gdc_read __P((struct vga_handle *, int));
     44 static inline void _vga_gdc_write __P((struct vga_handle *, int, u_int8_t));
     45 
     46 static inline u_int8_t _vga_6845_read(vh, reg)
     47 	struct vga_handle *vh;
     48 	int reg;
     49 {
     50 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_6845, VGA_6845_INDEX, reg);
     51 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, VGA_6845_DATA));
     52 }
     53 
     54 static inline void _vga_6845_write(vh, reg, val)
     55 	struct vga_handle *vh;
     56 	int reg;
     57 	u_int8_t val;
     58 {
     59 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_6845, VGA_6845_INDEX, reg);
     60 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_6845, VGA_6845_DATA, val);
     61 }
     62 
     63 static inline u_int8_t _vga_attr_read(vh, reg)
     64 	struct vga_handle *vh;
     65 	int reg;
     66 {
     67 	u_int8_t res;
     68 
     69 	/* reset state */
     70 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     71 
     72 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
     73 	res = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAR);
     74 
     75 	/* reset state XXX unneeded? */
     76 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     77 
     78 	/* enable */
     79 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
     80 
     81 	return (res);
     82 }
     83 
     84 static inline void _vga_attr_write(vh, reg, val)
     85 	struct vga_handle *vh;
     86 	int reg;
     87 	u_int8_t val;
     88 {
     89 	/* reset state */
     90 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     91 
     92 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
     93 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAW, val);
     94 
     95 	/* reset state XXX unneeded? */
     96 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     97 
     98 	/* enable */
     99 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
    100 }
    101 
    102 static inline u_int8_t _vga_ts_read(vh, reg)
    103 	struct vga_handle *vh;
    104 	int reg;
    105 {
    106 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
    107 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA));
    108 }
    109 
    110 static inline void _vga_ts_write(vh, reg, val)
    111 	struct vga_handle *vh;
    112 	int reg;
    113 	u_int8_t val;
    114 {
    115 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
    116 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA, val);
    117 }
    118 
    119 static inline u_int8_t _vga_gdc_read(vh, reg)
    120 	struct vga_handle *vh;
    121 	int reg;
    122 {
    123 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
    124 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA));
    125 }
    126 
    127 static inline void _vga_gdc_write(vh, reg, val)
    128 	struct vga_handle *vh;
    129 	int reg;
    130 	u_int8_t val;
    131 {
    132 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
    133 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA, val);
    134 }
    135 
    136 #define vga_6845_read(vh, reg) \
    137 	_vga_6845_read(vh, offsetof(struct reg_6845, reg))
    138 #define vga_6845_write(vh, reg, val) \
    139 	_vga_6845_write(vh, offsetof(struct reg_6845, reg), val)
    140 #define vga_attr_read(vh, reg) \
    141 	_vga_attr_read(vh, offsetof(struct reg_vgaattr, reg))
    142 #define vga_attr_write(vh, reg, val) \
    143 	_vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val)
    144 #define vga_ts_read(vh, reg) \
    145 	_vga_ts_read(vh, offsetof(struct reg_vgats, reg))
    146 #define vga_ts_write(vh, reg, val) \
    147 	_vga_ts_write(vh, offsetof(struct reg_vgats, reg), val)
    148 #define vga_gdc_read(vh, reg) \
    149 	_vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg))
    150 #define vga_gdc_write(vh, reg, val) \
    151 	_vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val)
    152 
    153 
    154 int	vga_common_probe __P((bus_space_tag_t, bus_space_tag_t));
    155 void	vga_common_attach __P((struct device *, bus_space_tag_t,
    156 			       bus_space_tag_t, int));
    157 int	vga_is_console __P((bus_space_tag_t, int));
    158 
    159 int	vga_cnattach __P((bus_space_tag_t, bus_space_tag_t, int, int));
    160 
    161 struct wsscreen_descr;
    162 void vga_loadchars __P((struct vga_handle *, int, int, int, int, char *));
    163 void vga_setfontset __P((struct vga_handle *, int));
    164 void vga_setscreentype __P((struct vga_handle *,
    165 			    const struct wsscreen_descr *));
    166