Home | History | Annotate | Line # | Download | only in ic
vgavar.h revision 1.3.8.1
      1  1.3.8.1    bouyer /* $NetBSD: vgavar.h,v 1.3.8.1 2000/11/20 11:41:05 bouyer 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.1  drochner struct vga_handle {
     31      1.2  drochner 	struct pcdisplay_handle vh_ph;
     32      1.2  drochner 	bus_space_handle_t vh_ioh_vga, vh_allmemh;
     33      1.2  drochner 	int vh_mono;
     34      1.1  drochner };
     35      1.2  drochner #define vh_iot vh_ph.ph_iot
     36      1.2  drochner #define vh_memt vh_ph.ph_memt
     37      1.2  drochner #define vh_ioh_6845 vh_ph.ph_ioh_6845
     38      1.2  drochner #define vh_memh vh_ph.ph_memh
     39      1.1  drochner 
     40      1.1  drochner static inline u_int8_t _vga_attr_read __P((struct vga_handle *, int));
     41      1.1  drochner static inline void _vga_attr_write __P((struct vga_handle *, int, u_int8_t));
     42      1.1  drochner static inline u_int8_t _vga_ts_read __P((struct vga_handle *, int));
     43      1.1  drochner static inline void _vga_ts_write __P((struct vga_handle *, int, u_int8_t));
     44      1.1  drochner static inline u_int8_t _vga_gdc_read __P((struct vga_handle *, int));
     45      1.1  drochner static inline void _vga_gdc_write __P((struct vga_handle *, int, u_int8_t));
     46      1.1  drochner 
     47      1.1  drochner static inline u_int8_t _vga_attr_read(vh, reg)
     48      1.1  drochner 	struct vga_handle *vh;
     49      1.1  drochner 	int reg;
     50      1.1  drochner {
     51      1.1  drochner 	u_int8_t res;
     52      1.1  drochner 
     53      1.1  drochner 	/* reset state */
     54      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     55      1.1  drochner 
     56      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
     57      1.1  drochner 	res = bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAR);
     58      1.1  drochner 
     59      1.1  drochner 	/* reset state XXX unneeded? */
     60      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     61      1.1  drochner 
     62      1.1  drochner 	/* enable */
     63      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
     64      1.1  drochner 
     65      1.1  drochner 	return (res);
     66      1.1  drochner }
     67      1.1  drochner 
     68      1.1  drochner static inline void _vga_attr_write(vh, reg, val)
     69      1.1  drochner 	struct vga_handle *vh;
     70      1.1  drochner 	int reg;
     71      1.1  drochner 	u_int8_t val;
     72      1.1  drochner {
     73      1.1  drochner 	/* reset state */
     74      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     75      1.1  drochner 
     76      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_INDEX, reg);
     77      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_ATC_DATAW, val);
     78      1.1  drochner 
     79      1.1  drochner 	/* reset state XXX unneeded? */
     80      1.1  drochner 	(void) bus_space_read_1(vh->vh_iot, vh->vh_ioh_6845, 10);
     81      1.1  drochner 
     82      1.1  drochner 	/* enable */
     83      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, 0, 0x20);
     84      1.1  drochner }
     85      1.1  drochner 
     86      1.1  drochner static inline u_int8_t _vga_ts_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 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
     91      1.1  drochner 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA));
     92      1.1  drochner }
     93      1.1  drochner 
     94      1.1  drochner static inline void _vga_ts_write(vh, reg, val)
     95      1.1  drochner 	struct vga_handle *vh;
     96      1.1  drochner 	int reg;
     97      1.1  drochner 	u_int8_t val;
     98      1.1  drochner {
     99      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_INDEX, reg);
    100      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_TS_DATA, val);
    101      1.1  drochner }
    102      1.1  drochner 
    103      1.1  drochner static inline u_int8_t _vga_gdc_read(vh, reg)
    104      1.1  drochner 	struct vga_handle *vh;
    105      1.1  drochner 	int reg;
    106      1.1  drochner {
    107      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
    108      1.1  drochner 	return (bus_space_read_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA));
    109      1.1  drochner }
    110      1.1  drochner 
    111      1.1  drochner static inline void _vga_gdc_write(vh, reg, val)
    112      1.1  drochner 	struct vga_handle *vh;
    113      1.1  drochner 	int reg;
    114      1.1  drochner 	u_int8_t val;
    115      1.1  drochner {
    116      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_INDEX, reg);
    117      1.1  drochner 	bus_space_write_1(vh->vh_iot, vh->vh_ioh_vga, VGA_GDC_DATA, val);
    118      1.1  drochner }
    119      1.1  drochner 
    120      1.1  drochner #define vga_attr_read(vh, reg) \
    121      1.1  drochner 	_vga_attr_read(vh, offsetof(struct reg_vgaattr, reg))
    122      1.1  drochner #define vga_attr_write(vh, reg, val) \
    123      1.1  drochner 	_vga_attr_write(vh, offsetof(struct reg_vgaattr, reg), val)
    124      1.1  drochner #define vga_ts_read(vh, reg) \
    125      1.1  drochner 	_vga_ts_read(vh, offsetof(struct reg_vgats, reg))
    126      1.1  drochner #define vga_ts_write(vh, reg, val) \
    127      1.1  drochner 	_vga_ts_write(vh, offsetof(struct reg_vgats, reg), val)
    128      1.1  drochner #define vga_gdc_read(vh, reg) \
    129      1.1  drochner 	_vga_gdc_read(vh, offsetof(struct reg_vgagdc, reg))
    130      1.1  drochner #define vga_gdc_write(vh, reg, val) \
    131      1.1  drochner 	_vga_gdc_write(vh, offsetof(struct reg_vgagdc, reg), val)
    132      1.1  drochner 
    133      1.2  drochner #define vga_6845_read(vh, reg) \
    134      1.2  drochner 	pcdisplay_6845_read(&(vh)->vh_ph, reg)
    135      1.2  drochner #define vga_6845_write(vh, reg, val) \
    136      1.2  drochner 	pcdisplay_6845_write(&(vh)->vh_ph, reg, val)
    137      1.1  drochner 
    138      1.1  drochner int	vga_common_probe __P((bus_space_tag_t, bus_space_tag_t));
    139      1.1  drochner void	vga_common_attach __P((struct device *, bus_space_tag_t,
    140  1.3.8.1    bouyer 			       bus_space_tag_t, int,
    141  1.3.8.1    bouyer 			       paddr_t (*)(void *, off_t, int)));
    142      1.1  drochner int	vga_is_console __P((bus_space_tag_t, int));
    143      1.1  drochner 
    144      1.1  drochner int	vga_cnattach __P((bus_space_tag_t, bus_space_tag_t, int, int));
    145      1.1  drochner 
    146      1.1  drochner struct wsscreen_descr;
    147      1.1  drochner void vga_loadchars __P((struct vga_handle *, int, int, int, int, char *));
    148      1.3  drochner void vga_setfontset __P((struct vga_handle *, int, int));
    149      1.1  drochner void vga_setscreentype __P((struct vga_handle *,
    150      1.1  drochner 			    const struct wsscreen_descr *));
    151